feat(babel-jest): support collecting coverage from .mts, .cts (and other) files#15994
Open
domarmstrong wants to merge 1 commit intojestjs:mainfrom
Open
feat(babel-jest): support collecting coverage from .mts, .cts (and other) files#15994domarmstrong wants to merge 1 commit intojestjs:mainfrom
domarmstrong wants to merge 1 commit intojestjs:mainfrom
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
Istanbul only collects coverage from files listed in 'extension'. It has a [default list](https://github.com/istanbuljs/schema/blob/master/default-extension.js) of `.js, .cjs, .mjs, .ts, .tsx, .jsx`. Any other files are ignored. As babel-jest doesn't provide the extension, or a way to provide it yourself, there is currently no way to collect coverage from .mts, .cts files. I've [proposed adding them to the default Istanbul list](istanbuljs/schema#22). But in the same fashion that Jest removes all exclusions, it could also provide the extension of the file being transformed to allow Istanbul to collect it's coverage. I can't think of a situation where you would want a file transformed by babel, but not to be instrumented that wouldn't already be handled by jests coverage include/exclude config.
2c23656 to
8ca879c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Istanbul only collects coverage from files listed in the 'extension'. option. If not provided it has a default list of
.js, .cjs, .mjs, .ts, .tsx, .jsx. Any other files are ignored. As babel-jest doesn't provide the extension prop, or a way to provide it yourself, there is currently no way to collect coverage from .mts, .cts files. I've proposed adding them to the default Istanbul list. But in the same fashion that Jest removes all exclusions, it could also provide the extension of the file being transformed to allow Istanbul to collect it's coverage.I can't think of a situation where you would want a file transformed by babel, but not to be instrumented that wouldn't already be handled by jests coverage include/exclude config.
Test plan
I've confirmed it's now possible to collect coverage from .mts files with this change. (Screenshots from use on own codebase)
Before:

After:
