2
2
/* eslint-disable @typescript-eslint/no-explicit-any*/
3
3
import { getSkipFlag , deepMerge } from './utils'
4
4
import { SkipOption , TestPlaywrightConfigOptions } from '../types/global'
5
+ import { DEBUG_TIMEOUT , DEFAULT_TEST_PLAYWRIGHT_TIMEOUT } from './constants'
5
6
6
7
type TestType = 'it' | 'describe'
7
8
@@ -14,20 +15,26 @@ const DEBUG_OPTIONS = {
14
15
15
16
const runDebugTest = ( jestTestType : jest . It , ...args : any [ ] ) => {
16
17
const isConfigProvided = typeof args [ 0 ] === 'object'
18
+ const lastArg = args [ args . length - 1 ]
19
+ const timer = typeof lastArg === 'number' ? lastArg : DEBUG_TIMEOUT
17
20
// TODO Looks weird - need to be rewritten
18
21
let options = DEBUG_OPTIONS as TestPlaywrightConfigOptions
19
22
if ( isConfigProvided ) {
20
23
options = deepMerge ( DEBUG_OPTIONS , args [ 0 ] )
21
24
}
22
25
23
- jestTestType ( args [ isConfigProvided ? 1 : 0 ] , async ( ) => {
24
- const envArgs = await jestPlaywright . configSeparateEnv ( options , true )
25
- try {
26
- await args [ isConfigProvided ? 2 : 1 ] ( envArgs )
27
- } finally {
28
- await envArgs . browser ! . close ( )
29
- }
30
- } )
26
+ jestTestType (
27
+ args [ isConfigProvided ? 1 : 0 ] ,
28
+ async ( ) => {
29
+ const envArgs = await jestPlaywright . configSeparateEnv ( options , true )
30
+ try {
31
+ await args [ isConfigProvided ? 2 : 1 ] ( envArgs )
32
+ } finally {
33
+ await envArgs . browser ! . close ( )
34
+ }
35
+ } ,
36
+ timer ,
37
+ )
31
38
}
32
39
33
40
// @ts -ignore
@@ -48,14 +55,21 @@ const runConfigTest = (
48
55
playwrightOptions : Partial < TestPlaywrightConfigOptions > ,
49
56
...args : any [ ]
50
57
) => {
51
- jestTypeTest ( args [ 0 ] , async ( ) => {
52
- const envArgs = await jestPlaywright . configSeparateEnv ( playwrightOptions )
53
- try {
54
- await args [ 1 ] ( envArgs )
55
- } finally {
56
- await envArgs . browser ! . close ( )
57
- }
58
- } )
58
+ const lastArg = args [ args . length - 1 ]
59
+ const timer =
60
+ typeof lastArg === 'number' ? lastArg : DEFAULT_TEST_PLAYWRIGHT_TIMEOUT
61
+ jestTypeTest (
62
+ args [ 0 ] ,
63
+ async ( ) => {
64
+ const envArgs = await jestPlaywright . configSeparateEnv ( playwrightOptions )
65
+ try {
66
+ await args [ 1 ] ( envArgs )
67
+ } finally {
68
+ await envArgs . browser ! . close ( )
69
+ }
70
+ } ,
71
+ timer ,
72
+ )
59
73
}
60
74
61
75
//@ts -ignore
0 commit comments