globalSetup not executed on watch reload
See original GitHub issueDo you want to request a feature or report a bug? Feature
What is the current behavior?
When defining the globalSetup
config option along with --watch
, the globalSetup
script only executes the first time the tests are run, not after each reload.
What is the expected behavior?
It would be helpful to have some means of specifying a globalSetup
script which would continue to be executed before all tests run after each reload triggered by --watch
. Not sure if this ends up being a separate config option or what’s the best way of implementing it.
In terms of ‘why’, I’m using globalSetup
to reset a test database for some integration tests. It would help if this option allowed this reset to continue to occur as --watch
re-runs these tests.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Jest globalSetup option not working - Stack Overflow
I'm trying to make a function called loadFixtures available to all Jest tests. I have the following line within the jest config object...
Read more >Jest Global Setup - Part 10 - YouTube
Learn how to create a global setup when testing with Jest.
Read more >Organizing tests with jest projects - Jakub Homoly
Setting up multiple test suites with jest can be labor intesive. In this article, you will learn about the powerful projects feature of...
Read more >Automatically restart Node.js apps with Nodemon
The essential tutorial for Nodemon, a utility for Node.js applications that monitors for changes and automatically restarts the server.
Read more >Configuring Vitest
If you are running Vitest with --no-threads flag, your tests will be ... Beware that the global setup is run in a different...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well; it seems to be working as expected in my new minimal jest + TS setup, must be something else in my config. Sorry for the false alarm, I’ll report back if I figure anything else out.
Hey @Surreal9 I can’t seem to replicate this behaviour.
I am able to run a
globalSetup
script in watch mode which logs the current date every time the tests are re-ran by hittinga
orENTER
or from file changes.Example
globalSetup
script:Would you be able to create a repro to demo the issue?