-
Notifications
You must be signed in to change notification settings - Fork 453
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
Use "canonical" Jest configuration #312
Conversation
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 a little worried about the coverage changing. Are you saying the new regex only matches files in tests folders? I think we should lean on the original jest regex which iirc matches all files in tests and everything called eg .spec.ts and .test.ts |
I actually prefer that change. It sort of standardizes how we structure our tests. |
Talking about
Talking about |
Instead of differentiating tests based on a small part of their filenames (spec.ts vs test.ts), I suggest to create 2 separated directories: makes things clear about having 2 types of tests. |
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.
It does what it's intended to do. I'm OK with separating two kinds of tests in two folders.
This will be for another PR |
I have strong opinions on some of this. I'll get back to it after the weekend |
In regards to the regex I think as stated previously:
While other conventions might make more sense, I'd hate for someone to convert their js to typescript and then go 'Oh my god why don't half my tests run' - I think it should basically be a carbon-copy of the default config from jest. I don't have time to take a look at the coverage atm, but it's really fkn weird. Maybe there's a some version mixup going on? It makes no sense to me that the coverage would change. |
The regex used in the documentation seems to be a copy of that from Jest. It's only in the tests for this repo that the regex is specific to this repo. That's what I was alluding to when I said it sort of standardizes how we structure our tests
The coverage bit confounded me a bit too but then seeing that I didn't entirely understand how it exactly worked in the first place (which lines it ignored, etc), this version doesn't look that different. So I'm kinda ok with it. I'll let @tkrotoff chime in on this. |
I actually thought the jest regex matched both files in tests and .test and .spec everywhere. If they're the same, I'm fine with it. |
The original regex in our (ts-jests's) |
Following #310
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
should be
"^.+\\.tsx?$"
see 1, 2, 3"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$"
should be
"(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$"
see 1, 2Is
"^.+\\.tsx?$"
that different from".(ts|tsx)"
? I can't explain it but it changes the coverage results for thesimple
andsimple-async
tests:".(ts|tsx)"
:"^.+\\.tsx?$"
:And I believe the results with
"^.+\\.tsx?$"
are the correct ones.As for root
package.json
, I've changed"testRegex": "/__tests__/.*\\.(spec)\\.(ts|js)$"
to"tests/__tests__/.*\\.spec\\.ts$"
.The path is now hardcoded to be sure to only match files
tests/__tests__/*.spec.ts
and not the others that end with.test.ts
(differentiate test categories with.spec.ts
vs.test.ts
is dangerous IMHO).