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.

Document globalSetup usage

See original GitHub issue

In the documentation there is reference to setting up authentication in globalSetup and then sharing that login across all test runs:

  1. Run tests (for example, with npm run test).
  2. Login via UI and retrieve authentication state.
    • In Jest, this can be executed in globalSetup.
  3. 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:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mmarkelovcommented, Mar 7, 2021

@Xezed I’m going to work on this. I think it can be helpful. But it will quite difficult to rewrite

0reactions
Xezedcommented, Mar 14, 2021

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

Read more comments on GitHub >

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

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