1
- // @ts -nocheck
2
1
import JestRunner from 'jest-runner'
3
- import playwright from 'playwright-core'
4
2
import type {
5
3
Test ,
6
4
TestRunnerContext ,
@@ -17,6 +15,8 @@ import {
17
15
checkDeviceEnv ,
18
16
getDisplayName ,
19
17
readConfig ,
18
+ getPlaywrightInstance ,
19
+ readPackage ,
20
20
} from './utils'
21
21
import { DEFAULT_TEST_PLAYWRIGHT_TIMEOUT } from './constants'
22
22
@@ -33,11 +33,14 @@ const getBrowserTest = (
33
33
...test . context ,
34
34
config : {
35
35
...test . context . config ,
36
+ // @ts -ignore
36
37
browserName : browser ,
37
38
device,
38
39
displayName : {
39
40
name : displayName
40
- ? `${ playwrightDisplayName } ${ displayName . name } `
41
+ ? `${ playwrightDisplayName } ${
42
+ typeof displayName === 'string' ? displayName : displayName . name
43
+ } `
41
44
: playwrightDisplayName ,
42
45
color : 'yellow' ,
43
46
} ,
@@ -46,17 +49,22 @@ const getBrowserTest = (
46
49
}
47
50
}
48
51
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 (
51
55
tests . map ( async ( test ) => {
52
56
const { rootDir } = test . context . config
53
57
const { browsers, devices } = await readConfig ( rootDir )
54
58
return browsers . flatMap ( ( browser ) => {
55
59
checkBrowserEnv ( browser )
56
- return devices . length
60
+ const { devices : availableDevices } = getPlaywrightInstance (
61
+ playwrightPackage ,
62
+ browser ,
63
+ )
64
+ return devices
57
65
? devices . flatMap ( ( device ) => {
58
- const availableDevices = Object . keys ( playwright . devices )
59
- checkDeviceEnv ( device , availableDevices )
66
+ const availableDeviceNames = Object . keys ( availableDevices )
67
+ checkDeviceEnv ( device , availableDeviceNames )
60
68
return getBrowserTest ( test , browser , device )
61
69
} )
62
70
: getBrowserTest ( test , browser , null )
@@ -87,14 +95,14 @@ class PlaywrightRunner extends JestRunner {
87
95
const browserTests = await getTests ( tests )
88
96
89
97
return await ( options . serial
90
- ? this . _createInBandTestRun (
98
+ ? this [ ' _createInBandTestRun' ] (
91
99
browserTests ,
92
100
watcher ,
93
101
onStart ,
94
102
onResult ,
95
103
onFailure ,
96
104
)
97
- : this . _createParallelTestRun (
105
+ : this [ ' _createParallelTestRun' ] (
98
106
browserTests ,
99
107
watcher ,
100
108
onStart ,
0 commit comments