feat(ci): Add junit reporters to jest/vitest, codecov test results#15341
feat(ci): Add junit reporters to jest/vitest, codecov test results#15341
Conversation
.github/workflows/build.yml
Outdated
| continue-on-error: true | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| files: packages/**/*.xml |
There was a problem hiding this comment.
You have hard-coded the path to the test results. This could potentially cause problems when the project structure changes. Consider moving this into a configuration file or an environment variable so that any potential changes in the project structure are easier to manage.
vite/vite.config.ts
Outdated
| enabled: true, | ||
| reportsDirectory: './coverage', | ||
| }, | ||
| reporters: ['default', 'junit'], |
There was a problem hiding this comment.
You have chosen to use both the 'default' and 'junit' reporters. Ensure that using both these reporters together does not produce conflicting or duplicate reports.
| version "16.0.0" | ||
| resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-16.0.0.tgz#d838e8c561cf9fdd7eb54f63020777eee4136785" | ||
| integrity sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ== | ||
| dependencies: |
There was a problem hiding this comment.
The addition of the jest-junit package has introduced several new dependencies. Make sure these new dependancies do not cause conflicts with existing code or other packages.
vite/vite.config.ts
Outdated
| enabled: true, | ||
| reportsDirectory: './coverage', | ||
| }, | ||
| reporters: ['default', 'junit'], |
There was a problem hiding this comment.
Ensure that the junit reporter does not conflict with other reporters. Also, make sure it's supported by the installed version of vitest.
| reportsDirectory: './coverage', | ||
| }, | ||
| reporters: ['default', 'junit'], | ||
| outputFile: { |
There was a problem hiding this comment.
Double check the jest configurations and make sure that outputFile is a valid configuration option, as it's not recognized in the base jest configuration.
| coverage: {}, | ||
| globals: true, | ||
| setupFiles: ['./setup-test.ts'], | ||
| reporters: ['default'], |
There was a problem hiding this comment.
The 'default' reporter was removed from some vitest configurations, but it might be beneficial to leave this for local development. If you're aiming to use Junit reporter on CI and default reporter locally, you might want to consider a conditionally loaded configuration based on the environment (development vs CI).
vite/vite.config.ts
Outdated
| enabled: true, | ||
| reportsDirectory: './coverage', | ||
| }, | ||
| reporters: ['default', ...(process.env.CI ? ['junit'] : [])], |
There was a problem hiding this comment.
The test results filename should probably include the names of the individual test suites to prevent them from overwriting each other. Consider dynamically generating the output filename based on the test suite name.
| continue-on-error: true | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| directory: dev-packages/node-integration-tests |
| continue-on-error: true | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| directory: packages/remix |
| continue-on-error: true | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| files: packages/**/*.junit.xml |
There was a problem hiding this comment.
| continue-on-error: true | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| files: packages/**/*.junit.xml |
There was a problem hiding this comment.
|
This brings the number of tests tracked from ~700 to 4.5k |
joseph-sentry
left a comment
There was a problem hiding this comment.
lgtm from my end, just one optional enhancement you can make to the jest config to get some nice formatting for test names in the codecov UI
i see now that specifying the files using globs was necessary for the browser unit tests, although i'd expect the CLI to find those files, so i'll make an issue to look into that here
Co-authored-by: joseph-sentry <[email protected]>
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
I noticed that not all of our tests were being tracked in codecov. This adds
jest-junitreporter for our jest tests and configures vitest to use junit reporter (whenCIenv var is set).This brings the number of tests tracked from ~700 to 4.5k