1- // @ts -nocheck
21import JestRunner from 'jest-runner'
3- import playwright from 'playwright-core'
42import type {
53 Test ,
64 TestRunnerContext ,
@@ -17,6 +15,8 @@ import {
1715 checkDeviceEnv ,
1816 getDisplayName ,
1917 readConfig ,
18+ getPlaywrightInstance ,
19+ readPackage ,
2020} from './utils'
2121import { DEFAULT_TEST_PLAYWRIGHT_TIMEOUT } from './constants'
2222
@@ -33,11 +33,14 @@ const getBrowserTest = (
3333 ...test . context ,
3434 config : {
3535 ...test . context . config ,
36+ // @ts -ignore
3637 browserName : browser ,
3738 device,
3839 displayName : {
3940 name : displayName
40- ? `${ playwrightDisplayName } ${ displayName . name } `
41+ ? `${ playwrightDisplayName } ${
42+ typeof displayName === 'string' ? displayName : displayName . name
43+ } `
4144 : playwrightDisplayName ,
4245 color : 'yellow' ,
4346 } ,
@@ -46,17 +49,22 @@ const getBrowserTest = (
4649 }
4750}
4851
49- const getTests = ( tests : Test [ ] ) : Promise < Test [ ] > => {
50- return Promise . all (
52+ const getTests = async ( tests : Test [ ] ) : Promise < Test [ ] > => {
53+ const playwrightPackage = await readPackage ( )
54+ return await Promise . all (
5155 tests . map ( async ( test ) => {
5256 const { rootDir } = test . context . config
5357 const { browsers, devices } = await readConfig ( rootDir )
5458 return browsers . flatMap ( ( browser ) => {
5559 checkBrowserEnv ( browser )
56- return devices . length
60+ const { devices : availableDevices } = getPlaywrightInstance (
61+ playwrightPackage ,
62+ browser ,
63+ )
64+ return devices
5765 ? devices . flatMap ( ( device ) => {
58- const availableDevices = Object . keys ( playwright . devices )
59- checkDeviceEnv ( device , availableDevices )
66+ const availableDeviceNames = Object . keys ( availableDevices )
67+ checkDeviceEnv ( device , availableDeviceNames )
6068 return getBrowserTest ( test , browser , device )
6169 } )
6270 : getBrowserTest ( test , browser , null )
@@ -87,14 +95,14 @@ class PlaywrightRunner extends JestRunner {
8795 const browserTests = await getTests ( tests )
8896
8997 return await ( options . serial
90- ? this . _createInBandTestRun (
98+ ? this [ ' _createInBandTestRun' ] (
9199 browserTests ,
92100 watcher ,
93101 onStart ,
94102 onResult ,
95103 onFailure ,
96104 )
97- : this . _createParallelTestRun (
105+ : this [ ' _createParallelTestRun' ] (
98106 browserTests ,
99107 watcher ,
100108 onStart ,
0 commit comments