-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
--findRelatedTests <spaceSeparatedListOfSourceFiles> don't find test file if path include special characters and file extension #11534
Comments
|
Ok so if we set absolute path in tsconfig like below, we cannot use "paths": {
"@core/*": ["./src/app/@core/*"],
"@shared/*": ["./src/app/@shared/*"],
"@environments/*": ["./src/environments/*"]
} I'm perplexed by your answer. my |
|
That's exactly what i mean.
I'm not using tsconfig path with jest --findRelatedTests. I'm using reel hard drive paths.
So i think there is definitly a bug. My architecture folder are (i mean, on the hard drive, not computed by any tsconfig / typescript paths option) like this : ├── src (application codebase)
│ ├── app
│ │ ├── @core (local libraries)
│ │ ├── @shared (shared modules)
│ │ ├── styles (shared styles)
│ │ └── ... (main modules and views) I'm using What i mean is when i'm asking jest with And why i'm supposing a special characters bug, this is because |
Ok i worked a bit more to show you. This is a really strange behavior. git clone https://github.com/blephy/jest-path-bug.git
cd jest-path-bug
npm i
npm run test:every
# look at the package.json to see paths I don't know what to think about. The bug appears more complicated as expected.
If it's a desired behavior, the behavior is painfull. I prefer to believe it's a bug. In my opinion, we need some investigations EDIT: i saw a lot of clone, please |
What about this contract (by order of preference) :
npx jest --findRelatedTests src/app/@core/store/store.ts
# jest should try to find a test file at src/app/@core/store/store.(spec|test).ts
npx jest --findRelatedTests src/app/@core/store/store
# jest should try to find all test files in src/app/@core/store/store if a folder exist (src/app/@core/store/store/*.(spec|test).(.js|.jsx|.ts|.tsx)
# if no folder exist or no spec files found in the existing folder, jest should try to find a test file at src/app/@core/store/store.(spec|test).(js|jsx|ts|tsx) |
I like the suggestion. cc @SimenB |
If it's ok for you, in my opinion, you will need to compute a regExp based on the path entry, but the hard work is to include the jest config, which permit to specified a test file pattern if i remember correctly. And the other hard work is to not run any same files which is included in different paths for the same commands. @nicojs can you give us your Facebook, If you need some help, i would be glad ;) |
Just for your team, this issue is also related to #11527 |
@blephy Thanks for all your hard work on this issue 🎉 StrykerJS uses @blephy's suggestion would work for us. We mostly need a "bugfree" version of However, from Jest's point of view, it would be technically impossible to know the difference between path that includes a file extension vs one that doesn't without performing disk IO. For example, "foo.bar" might refer to a file with name "foo" with extension ".bar", or it could refer to a directory "foo.bar" which contains files. I would suggest the following:
|
You're welcome
That's why stryker takes 2 days to run on my repository (29K lignes of es6 code without comments / spaces, cpu runner free of other task) because in my case i must use |
While we're at it: #9728 is also a big hurdle for StrykerJS users 😇 |
I've noticed that this only seems to affect Windows. On Linux (WSL):
I'll try to debug to see what's going on here. |
@nicojs you rock 🥰 |
Just for posterity : Here is an update of the repository which help us to demonstrate the issue. I'm linking the CI which runs on multiple OS and node versions.
The bug is fixed but it seems that Thanks for the work. |
Cool! Thanks for checking it out @blephy |
You're welcome |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Hi guys,
Implementing Stryker on my repository was a really difficult task and after searching why jest give me a lot of additional work, i'm openning this issue.
I think the code responsibly to parse and find test paths with the
--findRelatedTests
contains (maybe, i'm not sure) a bug.Every things is explained in this other issue but to summarize, in my context i have an angular project which is running with jest.
Architecture folders are like this :
├── src (application codebase) │ ├── app │ │ ├── @core (local libraries) │ │ ├── @shared (shared modules) │ │ ├── app │ │ ├── ** (main views / containers)
if i run
npx jest --findRelatedTests src/app/app.module.ts
everything is ok. Jest found 2 spec files. (except 240 seconds is needed to pass them ... for just 2 assertions - codebase = 29K pure ligne of code)if i run
npx jest --findRelatedTests src/app/@core/store/store.ts
jest stdout this :To Reproduce
Expected behavior
Jest should understand paths with special characters and with or without file extensions
envinfo
Regards !
and many thanks about maintaining jest ;)
The text was updated successfully, but these errors were encountered: