-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
--generateCoverageForFiles #4246
--generateCoverageForFiles #4246
Conversation
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites matching /a.js/i. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is incorrect (also broken in master for --findRelatedTests
)
i filed the issue #4247
b225d84
to
bb51c6e
Compare
// should only run a.js | ||
expect(rest).toMatchSnapshot(); | ||
// coverage should be collected only for a.js | ||
expect(stdout).toMatchSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, not really needed here, but recently I came up with more descriptive snapshot testing such scenarios:
describe(('--generateCoverageForFiles') => {
test('summary', () => expect(summary).toMatchSnapshot())
test('rest', () => expect(rest).toMatchSnapshot())
test('stdout', () => expect(stdout).toMatchSnapshot())
})
This gives more descriptive snapshot names, together with error messages when diffing later (it's easy to loose context in large snapshots, and names are easier to understand than checking which number is for which snap)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait.. are you running the subprocess outsude of test
?
i agree that snapshots are hard to track!
// `--findRelatedTests '/rootDir/file1.js' --coverage --collectCoverageFrom 'file1.js'` | ||
// where arguments to `--collectCoverageFrom` should be globs (or relative | ||
// paths to the rootDir) | ||
if (argv.generateCoverageForFiles) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we good that it's only for CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah! i don't think we'd want to put it in a config, since it's a very interactive option :)
website build travis and appveyor seems to be failing for unrelated reasons :( |
|
||
test('--generateCoverageForFiles', () => { | ||
writeFiles(DIR, { | ||
'.watchmanconfig': '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think if you have watchman installed on your computer (which we have at fb) it'll complain in stdout if this file is not present, which will in turn make it harder to snapshot the output :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's worth creating a wraper function createJestProject()
that'll add it by default.
but at the same time i'd rather keep it explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for explicitness here, it's easier not to loose the context
I'm not opposed to adding this option, however I don't think the naming makes sense. It implies that it will collect coverage but does not imply that tests will be run. How about The latter argument will turn on collection for all patterns that are passed in to Jest. It'll collect coverage for file1 and file2, but not file3, for example. What do you think? Also, I'm not sure how this speeds up |
|
maybe something like |
All of this kind of hints at the cli becoming unwieldy and overly complex :( Do you have any ideas what we could do about that? |
jest --coverage # All
jest --coverage file.test.js ... # Only for files/patterns given as arguments ? |
@michael-ciniawsky we can't do this, because by default jest expect test patterns to be passed in, and we don't collect coverage for test files. |
Ohh sry, I see what you mean 😛, should be e.g |
…Changed` and `--watch` scenarios (#5601) * Jump start using the work from #4246 * checking how it looks without an extra flag * makes more sense to colocate the test here * remove mystery files * remove references to the flag * update docs * add test case for --onlyChanged and --coverage * update snapshot to what it should be * apply collectCoverageFrom patterns after finding tests * Collect possible coverage patterns while searching for tests * improve test results * hi there flow * skip on windows * will the windows build pass this time? * fix test on windows * remove underscore as it's no longer a private api * polymorphing * simplify test * increase test coverage in jest-config/normalize * make the linter happy again * should use argv as it's not a config option * test coverage for run_jest * update snapshots * remove object spread, replaced with Object.assign * add changelog entry
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
fixes #4245