-
-
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
Taking 10 seconds on an empty repo, #1986
Comments
Is it possible your anti-virus software is invoked on every file system access within your project? Can you try whitelisting this folder and re-running Jest? This is a common problem on Windows. |
I disabled anti-virus completely, also disabled firewall and search indexing just to be sure and rebooted but still no improvement. I tried a couple different options, Docker, Windows Ubuntu bash, and it does perform better in those (in some cases) down to 6 secs on this test project and on my original project from 2mins to 20 secs. But those systems seem to have problems of their own making them not ideal for development. So this is definitely a Windows issue, but not related to anti-virus. Please let me know if and how I can help debug this further. I would really love to use Jest but natively on Windows! |
Comparison on other systems I tried and their shortcomings:
Windows Ubuntu Bash works best but only with VolFs which isn't ideal for development because files in that system don't work well with native Windows tools (editing outside of bash breaks them). Docker works well but only when you copy the contents to the image, which won't work for active development. Unfortunately mounted volumes has it's own issues with Docker (on Windows at least) which causes it to be still slow. This is particularly visible on a bigger project. Windows Ubuntu Bash with mounted filesystem (DriveFS /mnt/c/...), which is the ideal file system for active development, it's actually worse, taking 20 secs! I saw improvement on my original project which was taking 2+ mins which has come down to ~20 secs with Docker and Windows Ubuntu Bash with native VolFs, but neither of those options seem ideal. |
On Windows we cannot use either watchman or the We have to do this on every startup of Jest, unfortunately, to do static analysis (like for the watch mode or for |
I found that it monitors (putting Specifying "testPathDirs" resolves this, but it should ignore Although as you see, this by itself was still pretty quick. The delay almost certainly seems to be on the "RUNS". Could you please also point to the file where "RUNS" happen in the code. Thanks |
When Jest prints "RUNS" it means it is already running the code inside your tests. Maybe you can add some instrumentation ( |
So I did console.time('startSync');
console.time('startASync');
describe('simple', () => {
it('test', () => {
console.timeEnd('startASync');
});
});
console.timeEnd('startSync');
As seen, the time it takes to run, as reported by console.time (7-30ms) and by Jest itself ( But the It's definitely doing something other than just running the test files between the time it displays And since *console logs are globbed up by Jest and only shown at the end (bw any way to turn this off temporarily?) I can't tell whether it starts running the file as soon as it displays "RUNS" or after 11 secs, mainly in the last few seconds. I'm betting on the latter. PS: Also notice the timers BTW, how much, according to you, should be the time taken ideally for this simple test? 1 sec? 5-6? EDIT: Using Date.now (instead of console.time) and calculating diff to workaround that *console.log issue:
The difference between when it prints RUNS and when it actually starts the test code (startSync) is 11 secs |
It just looked at it, the test run should certainly complete in less than a second. This is really odd. Is it at all different if you do |
I did a I've narrowed it down to the following statements that are causing the delay: jest-cli/src/TestRunner.js#L304
jest-jasmine2/src/index.js#L110
After this it goes into jest-runtime's requireModule which _execModule's a lot of modules (is that expected behaviour? even with |
Interesting. Are you using npm2? I would recommend to upgrade to yarn or npm3 to install Jest which will result in a lot fewer modules that will be required per context. |
Closing for now as I don't think this is actionable. If there are issues in Jest that we can fix, please comment here or send a PR and I'll reopen this issue. |
Sorry I couldn't debug this further earlier. I was actually using npm3 and yarn. In fact in all these tests I had no other dependencies than Jest itself (which was set up via Lerna). You didn't answer my question earlier: [...] After this it goes into jest-runtime's requireModule which _execModule's a *lot of modules* -- is that expected behaviour? even with |
Jest does require a ton of modules, yes, but normally that shouldn't take more than ~10ms. The paths very much look like the node_modules folder wasn't deduplicated, which is really odd. You should only have |
I'm having the same problems on node
46 seconds is outrageous. I have already tried nuking |
Consequent runs take ~7 seconds:
|
Same for me, I'm running enzyme example repo and it takes 7-10 seconds. The assertions itself takes only 50ms. |
@apieceofbart You could start by confirming whether you're getting the same delays as me on breakpoints I mentioned above #1986 (comment) Specially the last one:
|
@laggingreflex thanks! From there till the end it's similar to your case. I will keep posting other findings. |
@laggingreflex |
@apieceofbart can you try Jest has to read files from disk to load and run them. What you are pointing to are the pieces of code that executes node modules and user code. It may be that your harddrive is very slow or your anti-virus scanner looks at all the node_modules. If you make an exception for your projects, all your tools may be faster. |
bingo! This brings creating test env from 2s to 15ms. However this I have just bought a new SSD laptop and whitelisted my projects folder in anti-virus scanner (even removing the scan completely) and it doesn't help. Thanks for your concern, I will let you know if find anyhing. |
I had similar observation, running jest inside Docker on macOS with alpine-node image (and the app bootstrapped with I was running Results
ReasonIn my case, the cause was the well known problem of slow Docker mounts on macOS. The whole issue thread here: docker/for-mac#77 Solution (until the mounts get faster)For now, I just mount my QuestionI know, that my solution does not update |
For Windows, could this and various similar issues on yarn be related?: yarnpkg/yarn#1496 yarnpkg/yarn#990 (just a hunch, haven't checked these out in detail). In yarnpkg/yarn#2958 OP mentioned a Windows specific nodejs bug in |
We have a similar problem, we are importing
It seems this happens when its using Not entirely sure if its related or if jest have a threshold but after loading this specific test its failing other tests without a message (however the tests alone works). This is the error im getting
This is the last test I need to get working to switch to jest from jasmine which unfortunately its blocking me update: last part was failing because of running in parallel for some reason, i had to use using
|
I am using Jest (and enzyme) in create-react-app and adding a |
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. |
I'm new to jest and I heard about it being slow so I was expecting it. But the main project I integrated Jest in was actually taking upwards of 2 mins! I might be doing something wrong, but even on this empty test repo it's taking 10+ seconds: https://github.com/laggingreflex/jest-test
Do you want to request a feature or report a bug?
Bug/question?
What is the current behavior?
Jest is taking upwards of 12 seconds on an empty repo - it only has 2 empty test files (empty describe and it with nothing in them), and no actual code or dependencies (other than jest).
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can
npm install
andnpm test
.https://github.com/laggingreflex/jest-test
What is the expected behavior?
it should be faster...
Run Jest again with
--debug
and provide the full configuration it prints. Please mention your node and npm version and operating system.The text was updated successfully, but these errors were encountered: