You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
Is there a way to list all the test files that don't have a runner @group? My team wants to add a git hook that makes sure every test in our project has at least one group (in case we forget to add a group to a new test file, since we want each to have at least one).
Right now I've got a script using jest --listTests to list the test files, and regex parsing each for /*...@group XXX...*/ at the top of the file. If there's a better way I'd love to know! :)
The text was updated successfully, but these errors were encountered:
This is what I'm going with for now (instead of a regex) after finding how you get the groups with jest-docblock:
import*asfsfrom"fs";import*asdocblockfrom"jest-docblock";// Based on https://github.com/eugene-manuilov/jest-runner-groups/blob/3c9d3cf4cb3e595bdea733100f2bdc8d64f871d7/index.js#L36-L51functiongetJestRunnerGroups(file: string): Array<string>{constparsed=docblock.parse(fs.readFileSync(file,"utf8"));if(!parsed.group)return[];constgroups=Array.isArray(parsed.group) ? parsed.group : [parsed.group];returngroups.filter((group)=>typeofgroup==='string')}
I'm just curious because at the moment I'm defining the testing setup for a large project and I'm torn between multiple jest config files (own config for each group) and this jest-runner-groups package.
Since I only consider one group per file (xxxx.unit.test.ts for unit tests and xxxx.component.test.ts for component tests) I tend to rather use multiple configs with different filename regex. However I'm wondering if I oversee some benefits of defining multiple groups per file.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is there a way to list all the test files that don't have a runner
@group
? My team wants to add a git hook that makes sure every test in our project has at least one group (in case we forget to add a group to a new test file, since we want each to have at least one).Right now I've got a script using
jest --listTests
to list the test files, and regex parsing each for/*...@group XXX...*/
at the top of the file. If there's a better way I'd love to know! :)The text was updated successfully, but these errors were encountered: