Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

Test annotations for Jest using GitHub Actions #470

Open
@riaanduplessis

Description

@riaanduplessis

What is the hypothesis?

Feedback on pull requests, as well as the review experience, can be improved using automatic inline annotations that show on what lines the tests failed.

Why is this important?

It avoids the need to move between the actions tab and the pull request, although not a major inconvenience, this might be daunting for trainees since the job run page contains a lot of information that they might not be comfortable with yet. It might be hard for them to even find the actual test output and make sense of what is failing.

This would also improve reviewing by showing exact information as to why and where a trainee's code is failing, which the reviewer can then immediately comment on to provide feedback and resources, thus also increasing the speed of reviews.

Supporting Resources

Screenshot 2022-08-03 at 19 21 56

GitHub Action:

Note Coverage can be disabled and only use failure annotations

https://github.com/marketplace/actions/jest-coverage-report

Partial real-world example:

    # The first job is for creating the test report and uploading it as an artifact.

    # ...job setup, dependencies, etc. omitted for clarity...

    - name: Run tests
      run: npm test--json --outputFile=report.json # Note the output file

    - name: Upload Jest coverage report
      uses: actions/upload-artifact@v3
      with:
        name: jest-report # Note name for the artifact
        path: report.json 
        retention-days: 1

    # In a second job that runs only for pull-requests we download 
    # the artifact and use the jest-coverage-report action

    # ...job setup omitted for clarity...

    - name: Download Jest coverage report from test job
      uses: actions/download-artifact@v3
      with:
        name: jest-report

    - name: Annotate pull request
      uses: ArtiomTr/jest-coverage-report-action@v2
      with:
        skip-step: all # To disable auto-installing of dependencies and running tests
        coverage-file: report.json
        base-coverage-file: report.json
        annotations: failed-tests # Only failed test annotations, not coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    TDDEverything related to testing and the TDD stranddiscussionup for grabshttps://up-for-grabs.net/

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions