-
-
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
globalSetup and globalTeardown are ignored in projects. #5441
Comments
Can you please provide a repro which we can clone and run? |
@thymikee Sure, see https://github.com/deftomat/jest-global-setup-issue. Expected behaviour: Instead, they are ignored. It works only when you move them outside of e2e project. |
Also, I find out that globalSetup and globalTeardown are ignored when you use jest --projects packages/foo in yarn workspaces. Even when setup and teardown from foo package are not wrapped in "projects" property. So, basically the same error: setup and teardown are ignored if they are required by project. Using a jest --projects is just another way how to "wrap" them into a project. In another words: globalSetup and globalTeardown in any package are ignored when you try to run jest on multiple packages using --projects flag. |
any updates? |
Also having this problem when trying to run some test files with jest-puppeteer, and other test files with jsdom. Any workarounds? |
This comment has been minimized.
This comment has been minimized.
This is not specific to |
Sorry to spam this thread, but was wondering if anyone had come up with a workaround? I spin up some in memory mock stores etc, which are only applicable to certain projects within my monorepo. Ideally I'd like some mechanism of controlling the resources per project. |
@ctrlplusb If I understand correctly you'd like to run only the relevant A workaround would be to create a top-level I think a good solution would be to run a project's |
@ranyitz thanks for your comment, would be great to see a working example of a monorepo with that 😄 |
@mariogintili I started implementing the hacky way to do that, realizing it would be fairly easy to implement properly in Jest. We can call it Here an example: Some use the |
Happy to review a PR, but no guarantees it'll be merged 🙂 I like the idea, though! |
@SimenB Thanks, sounds fair 👍 |
I inspected the I need to be able to start the |
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
globalSetup
andglobalTeardown
are ignored when they are defined inside a project.If the current behavior is a bug, please provide the steps to reproduce
I'm using the following
jest.config.js
:What is the expected behavior?
I'm not sure if this is an expected behaviour or not. However, whey I try to use a non-existing file for a globalSetup / globalTeardown, then it throws the following error:
So, Jest is expecting an option like this in project.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest: v22.1.4
Node: v8.9.4
OS: macOS High Sierra
The text was updated successfully, but these errors were encountered: