question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

globalSetup not executed on watch reload

See original GitHub issue

Do 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:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Surreal9commented, Mar 21, 2018

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.

1reaction
mattphillipscommented, Mar 21, 2018

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 hitting a or ENTER or from file changes.

Example globalSetup script:

module.exports = () => console.log(new Date());

Would you be able to create a repro to demo the issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found