Giter VIP home page Giter VIP logo

jest-report-action's Introduction

Jest Github Actions Reporter

Creates annotations based on the output of jest-junit (see how to configure jest-junit properly) in your test files.

Example

.github/workflows/your-workflow.yml

    - uses: IgnusG/jest-report-action@v{ current version }
      if: always() # Or use "continue-on-error: true" in previous test step
      with:
        access-token: ${{ secrets.GITHUB_TOKEN }}

Example of Jest Annotations

Inputs

access-token - required

We'll need that to enrich the actions run with annotations. The secret is automatically generated by github.com.

junit-file - optional

The location and/or the name of the JUnit file. jest-junit uses junit.xml as a default, which is the default here too. If you haven't changed it, you can omit this input.

run-name - optional

The name of your run. This is typically build but can be configured individually. Make sure it matches your workflow config:

.github/workflows/your-workflow.yml

build: # <- this one!
    steps:
        ...

check-name - optional

A custom name that will appear in the PR's check window. Useful if you have multiple test suites - code, pipelines, publishing process etc., each run with separate jest commands.
Be sure to run this action after each jest run, that way you can use the same name for the JUnit file - or omit it.

Otherwise you have to give each generated JUnit file a unique name and pass it to jest-report-action.

working-directory - optional

The working directory, where the junit-file, as well as the sources (of test files) can be found. The default is the root directory of your project.

jest-junit Configuration

Have a look at how to call jest-junit in your workflows in the documentation. A very simple example is calling jest with a custom --reporters parameter:

package.json and other

  jest --ci --reporters=default --reporters=jest-junit

To provide correct annotation locations, you need to configure jest-junit to format the xml file in a compatible way.

Set these in either your package.json or through enviornment variables while running jest in your CI (Github).

package.json

"jest-junit": {
  "suiteNameTemplate": "{filepath}",
  "classNameTemplate": "{classname}",
  "titleTemplate": "{title}"
}

Refer to jest-junit Documentation to see other ways to configure these.

Thank you and have an amazing day!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.