Pass testEnvironmentOptions as part of globalConfig to globalSetup and globalTeardown.
See original GitHub issue🚀 Feature Proposal
I would like to be able to reference testEnvironmentOptions
inside of scripts passed in to globalSetup
(and teardown).
Motivation
I am writing a custom environment.
I have some global setup that I would like to do like:
- Start chromedriver service that I want to run for ALL test suites.
- Clear out the log directory from previous runs.
I want the parameters like
- Which port to run the driver on
- What the log directory is
to be defined in the
jest.config.js
. They are already defined there for me as part of my testEnvironmentOptions for my webdriver test environment. But the scripts inglobalSetup
andglobalTeardown
don’t have access to it.
Example
See motivation.
Pitch
This is the simplest change I can think of to accomplish what I need. I want to publish my jest-webdriver-environment, but right now I get around the limitation stated above by making fake projects
that contain the flags I want to pass, since projects
properties are considered part of the globalConfig
.
Thank you for considering this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Configuring Jest
Any global variables that are defined through globalSetup can only be read in globalTeardown . You cannot retrieve globals defined here in your...
Read more >Jest's globalSetup make my tests to not being recognized
If I remove globalSetup from jest.config.js, the tests appear although with errors because of mongo-enviroment and teardown configs been ...
Read more >jest-playwright-preset - npm Package Health Analysis - Snyk
And add the Jest command as in the script section of your package.json : ... Then assigning your js file paths to the...
Read more >cannot read property 'testenvironmentoptions' of undefined
Jest: testEnvironmentOptions cannot be read ... Open side panel ... async function that is triggered once before all test suites // globalSetup: undefined, ......
Read more >Jest: CHANGELOG.md - Fossies
[jest-snapshot] Pass snapshotFormat through when diffing snapshots ... Pass globalConfig as a parameter to globalSetup and globalTeardown ...
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
I still don’t fully understand, but it seems separate from what this PR asks for (which is already implemented). Could you open up a new feature request?
That said, we should have called
globalSetup
with an array of project configs, not just one. Might need to fix that in Jest 29.Closing since
projectConfig
is available todayThis 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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.