playwright-community / jest-playwright

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

"useDefaultBrowserType" property leads to "no tests were found" #782

Closed theBaldSoprano closed 2 years ago

theBaldSoprano commented 3 years ago

Describe the bug We set useDefaultBrowserType to true expecting preset to use default browser from playwright's deviceDescriptorsSource.json file. When running - we don't get any errors, but run passes with "no tests were found" message skipping all tests.

In general our intention is to use devices (playwright's or custom) with useDefaultBrowserType turned ON and do not specify any browser.

Also it seems like preset is bugging only with devices which have webkit or firefox set as default browser coz devices: ['Galaxy S8'] + useDefaultBrowserType: true seems to work fine.

To Reproduce

  1. specify configuration options via Jest's testEnvironmentOptions option in jest.config.js file
  2. add devices which have firefox or webkit defaults e.g. devices: ['JioPhone 2', 'iPhone XR']
  3. do not specify browsers option
  4. set useDefaultBrowserType to true
  5. launch test

Expected behavior Test will be run two times:

  1. in firefox on JioPhone 2
  2. in webkit on iPhone XR

Screenshots image

Desktop (please complete the following information):

Jest configuration (Either in the package.json > jest or in the jest.config.js):

'use strict';
const appConfig = require('./dist/backend/services/config');
const { defaults: tsjPreset } = require('ts-jest/presets');

const envMobileConfig = {
  devices: ['JioPhone 2', 'iPhone XR'],
  launchOptions: {
    headless: false,
  },
  exitOnPageError: false,
  useDefaultBrowserType: true,
};

module.exports = {
  reporters: ['default'],
  globalSetup: './testing/browser/configuration/globalSetup.js',
  globalTeardown: './testing/browser/configuration/globalTearDown.js',
  testEnvironment: './testing/browser/configuration/testEnvironment.js',
  setupFilesAfterEnv: ['./testing/browser/configuration/setupFilesAfterEnv.js'],
  moduleNameMapper: {
    '^@backend(.*)$': '<rootDir>/dist/backend$1',
    '^@frontedSrc(.*)$': '<rootDir>/frontend/src$1',
    '^@shared(.*)$': '<rootDir>/dist/shared$1',
    '^@configDir(.*)$': '<rootDir>/config$1',
  },
  forceExit: true,
  testRunner: 'jest-circus/runner',
  preset: 'jest-playwright-preset',

  testMatch: ['**/testing/browser/tests/**/?(*.)+(spec|test).+(*)+(ts)'],

  testSequencer: './testing/browser/configuration/customSequencer.js',
  transformIgnorePatterns: ['/node_modules/'],
  transform: {
    ...tsjPreset.transform,
  },
  testEnvironmentOptions: {
    'jest-playwright': envMobileConfig,
  },

  globals: {
    'ts-jest': {
      isolatedModules: true,
      tsconfig: './testing/tsconfig.json',
    },
    appUrl: appConfig.app.url,
  },
};

Additional context