playwright-community / jest-playwright

Running tests using Jest & Playwright
MIT License
532 stars 75 forks source link

ReferenceError: page is not defined after upgrading to version 2.0.0 and jest 28.1.3 #807

Closed Gorodb closed 2 years ago

Gorodb commented 2 years ago

After updating jest-playwright-preset to version 2.0.0 and jest to version 28.1.3 I got the error: (node:28292) UnhandledPromiseRejectionWarning: ReferenceError: page is not defined

Environment:

Jest configuration (jest.config.js):

module.exports = {
  preset: 'jest-playwright-preset',
  testEnvironment: "jest-allure-circus",
  testRunner: "jest-circus/runner",
  testMatch: ['**/__tests__/**/*.+(ts|js)', '**/?(*.)+(spec|test).+(ts|js)'],
  testTimeout: 30000,
  transform: {
    '^.+\\.ts$': 'ts-jest',
  },
  verbose: true,
  setupFilesAfterEnv: [
    './customMatchers.ts',
    './config.ts',
  ],
};

stylelint:

  "stylelint": {
    "plugins": [
      "eslint-plugin-jest",
      "eslint-plugin-playwright"
    ],
    "extends": [
      "plugin:playwright/jest-playwright"
    ]
  },

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "module": "commonjs",
    "sourceMap": true,
    "types": [
      "jest-playwright-preset",
      "@types/jest",
      "@types/node"
    ]
  },
  "exclude": [
    "node_modules"
  ]
}
Gorodb commented 2 years ago

It is because of testEnvironment: "jest-allure-circus"