Document globalSetup usage
See original GitHub issueIn the documentation there is reference to setting up authentication in globalSetup
and then sharing that login across all test runs:
- Run tests (for example, with npm run test).
- Login via UI and retrieve authentication state.
- In Jest, this can be executed in globalSetup.
- In each test, load authentication state in beforeEach or beforeAll step.
This seems to suggest a setup like:
// jest.config.js
module.exports = {
globalSetup: '<rootDir>/jest.globalSetup.js',
preset: 'jest-playwright-preset',
setupFilesAfterEnv: ['expect-playwright', '<rootDir>/jest.setup.js'],
}
But there is nothing playwright-related setup when globalSetup runs:
// jest.globalSetup.js
module.exports = async function globalSetup() {
console.log('setting up', Object.keys(global));
};
So does going this route require manually setting up playwright, or is there some way to get access to the instance that jest-playwright-preset creates?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
globalSetup() / setup() - Frisby.js
globalSetup (options). Set any global parameters, headers, etc. that need to be sent with each HTTP request that Frisby sends out. Most people...
Read more >How to use Jest global Setup and Teardown in a nodeJS ...
It means that we will establish a connection to the database FOR EVERY TEST FILE BEFORE ALL TESTS IN THAT FILE and close...
Read more >Jest Global Setup - Part 10 - YouTube
Learn how to create a global setup when testing with Jest.
Read more >Configuring Jest
You can use --config flag to pass an explicit path to the file. ... globals [object]; globalSetup [string]; globalTeardown [string] ...
Read more >Installation | jest-preset-angular - GitHub Pages
jest-preset-angular uses JSDOM which is different from normal browsers. ... Assuming that your global setup file is setup-jest.ts
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 Free
Top 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
@Xezed I’m going to work on this. I think it can be helpful. But it will quite difficult to rewrite
There is some misunderstanding happened. 😄 I’ve plunged into source code and found a way to absolutely satisfy my need. Created a pull request please merge it @mmarkelov 🙏 🙏 🙏