Skip to content
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

Jest's runInBand not compatible with incognito context #585

Open
opyate opened this issue Jul 12, 2024 · 0 comments
Open

Jest's runInBand not compatible with incognito context #585

opyate opened this issue Jul 12, 2024 · 0 comments

Comments

@opyate
Copy link

opyate commented Jul 12, 2024

From my package.json:

{
  "scripts": {
    "test": "SLOWMO=50 jest --runInBand",
    "testfast": "jest"
  },
  "dependencies": {
    "@types/jest": "^29.5.12",
    "@types/jest-environment-puppeteer": "^5.0.6",
    "@types/node": "^20.14.10",
    "@types/puppeteer": "^7.0.4",
    "@types/supertest": "^6.0.2",
    "dotenv": "^16.4.5",
    "jest": "^29.7.0",
    "jest-puppeteer": "^10.0.1",
    "puppeteer": "^22.13.0",
    "supertest": "^7.0.0",
    "ts-jest": "^29.2.2"
  }
}

Locally, I use test, and in CI environment I use testci. As tests are executed serially locally, I still expect cookies to be cleared for each test as I'm using an incognito context, but they aren't.

I've tried resetting the page in-between each test:

  beforeEach(async () => {
    jestPuppeteer.resetPage();
  });

But then I just get an error:

Error: Protocol error: Connection closed. Most likely the page has been closed.

I also thought about calling page.close() at the end of each test, then:

  beforeEach(async () => {
    page.isClosed() && (page = await browser.newPage());
  });

...but page can't be re-assigned, as it's a const.

Any suggestions would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant