Giter Site home page Giter Site logo

page is not defined about jest-playwright HOT 8 CLOSED

FezVrasta avatar FezVrasta commented on May 22, 2024 2
page is not defined

from jest-playwright.

Comments (8)

FezVrasta avatar FezVrasta commented on May 22, 2024 2

This is the whole repository, I'm trying to migrate from Puppeteer to Playwright:

https://github.com/popperjs/popper-core/tree/test/playwright

You can find the Jest configuration in the .config folder.

from jest-playwright.

mmarkelov avatar mmarkelov commented on May 22, 2024 1

@FezVrasta thank you!

from jest-playwright.

mmarkelov avatar mmarkelov commented on May 22, 2024

@FezVrasta I just made repo for example configuration. I suppose you need to define jest preset.

  • You can add it to your package.json:
  "jest": {
    "preset": "jest-playwright-preset"
  },
  • Or you can do it with jest.config.js file:
module.exports = {
    preset: "jest-playwright-preset"
}

I suppose it should be placed in README

from jest-playwright.

FezVrasta avatar FezVrasta commented on May 22, 2024

That's what I have done.

If I manually apply the globalSetup, globalTeardown and testEnvironment Jest configuration properties it works though...

My config looks like this:

module.exports = {
  preset: 'jest-playwright-preset',
  testMatch: ['<rootDir>/src/**/*.test.js', '<rootDir>/tests/**/*.test.js'],
  globals: {
    __DEV__: true,
  },
  // globalSetup: 'jest-environment-puppeteer/setup',
  // globalTeardown: 'jest-environment-puppeteer/teardown',
  // testEnvironment: 'jest-environment-jsdom-fourteen',
  setupFilesAfterEnv: ['<rootDir>/tests/setupTests.js'],
  reporters: ['default', require.resolve('../tests/image-reporter.js')],
  setupFiles: ['dotenv/config'],
  modulePathIgnorePatterns: ['tests/visual/dist'],
};

If I replace "preset" with:

  testEnvironment: 'jest-playwright-preset',
  globalSetup: 'jest-playwright-preset/setup',
  globalTeardown: 'jest-playwright-preset/teardown',

then it works correctly

from jest-playwright.

mmarkelov avatar mmarkelov commented on May 22, 2024

@FezVrasta it's difficult to say what is going wrong without whole configuration. I can only suppose that some of other options can override jest-playwright-preset. I'll try to dive into this issue to search possible problems.

from jest-playwright.

mmarkelov avatar mmarkelov commented on May 22, 2024

@FezVrasta I suppose this is because you define testEnvironment:
https://github.com/popperjs/popper-core/blob/fe24beeb92da1bb9573d2e6929940220008c263b/.config/jest.config.js#L6

And jest-playwright-preset like jest-puppeteer use it under hood.

I think this info should be added in README

from jest-playwright.

FezVrasta avatar FezVrasta commented on May 22, 2024

No that's not it, you can safely remove testEnvironment globalSetup and globalTeardown and add back preset and you will still reproduce the issue.

Also, I define test-environment with a jsdoc comment on each test that requires Playwright, so that would take precedence in any case. (and in fact it does, and manually specifying globalSetup and globalTeardown everything works)

The problem is with globalSetup and globalTeardown

from jest-playwright.

criles25 avatar criles25 commented on May 22, 2024

for others that stumble upon this issue... i had to comment out

testEnvironment: "node",  // comment this line out

the jest --init created this setting by default for the jest.config.js it generated.

from jest-playwright.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.