Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support jest coverage output #34

Closed
gregmagolan opened this issue Aug 10, 2022 · 2 comments
Closed

Support jest coverage output #34

gregmagolan opened this issue Aug 10, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@gregmagolan
Copy link
Member

See aspect-build/rules_js#337 for more context

@gregmagolan gregmagolan added the enhancement New feature or request label Aug 10, 2022
@gregmagolan gregmagolan added this to the 1.0 milestone Aug 10, 2022
@supercairos
Copy link

supercairos commented Nov 16, 2022

If it helps anyone,
I've managed to tricks Bazel into reading the outputed jest lcov using this jest config:

const path = require('path');

module.exports = {
  testEnvironment: 'node',
  reporters: ['default', ['jest-junit', { outputFile: process.env.XML_OUTPUT_FILE }]],
  testMatch: ['**/*.{test,spec}.js'],
  setupFiles: ['./test/.jest/set_env_vars.js'],
  collectCoverage: true,
  coverageDirectory: path.dirname(process.env.COVERAGE_OUTPUT_FILE),
  coverageReporters: ['text', ['lcovonly', { file: path.basename(process.env.COVERAGE_OUTPUT_FILE) }]],
};

@kormide kormide self-assigned this Nov 21, 2022
@gregmagolan
Copy link
Member Author

gregmagolan commented Nov 26, 2022

This should be easier to add now that jest_test generates a jest config file (added in 1141e1b) that we can add

  collectCoverage: true,
  coverageDirectory: path.dirname(process.env.COVERAGE_OUTPUT_FILE),
  coverageReporters: ['text', ['lcovonly', { file: path.basename(process.env.COVERAGE_OUTPUT_FILE) }]],

to when coverage is enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants