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.

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 in globalSetup and globalTeardown 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:closed
  • Created 3 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, May 2, 2022

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 today

0reactions
github-actions[bot]commented, Jun 2, 2022

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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

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

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