@@ -11,70 +11,70 @@ describe('static source analysis', () => {
11
11
; ( console . error as jest . Mock ) . mockRestore ( )
12
12
} )
13
13
it ( 'should extract config values from a source file' , async ( ) => {
14
- const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/background.js' ) )
14
+ const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/background.js' ) , process . cwd ( ) )
15
15
expect ( config ) . toEqual ( {
16
16
type : 'experimental-background' ,
17
17
} )
18
18
} )
19
19
it ( 'should extract config values from a TypeScript source file' , async ( ) => {
20
- const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/background.ts' ) )
20
+ const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/background.ts' ) , process . cwd ( ) )
21
21
expect ( config ) . toEqual ( {
22
22
type : 'experimental-background' ,
23
23
} )
24
24
} )
25
25
it ( 'should return an empty config if not defined' , async ( ) => {
26
- const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/missing.ts' ) )
26
+ const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/missing.ts' ) , process . cwd ( ) )
27
27
expect ( config ) . toEqual ( { } )
28
28
} )
29
29
30
30
it ( 'should return an empty config if config is invalid' , async ( ) => {
31
- const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/invalid.ts' ) )
31
+ const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/invalid.ts' ) , process . cwd ( ) )
32
32
expect ( config ) . toEqual ( { } )
33
33
} )
34
34
35
35
it ( 'should extract schedule values from a source file' , async ( ) => {
36
- const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/scheduled.ts' ) )
36
+ const config = await extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/scheduled.ts' ) , process . cwd ( ) )
37
37
expect ( config ) . toEqual ( {
38
38
type : 'experimental-scheduled' ,
39
39
schedule : '@daily' ,
40
40
} )
41
41
} )
42
42
it ( 'should throw if schedule is provided when type is background' , async ( ) => {
43
- await expect ( extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/background-schedule.ts' ) ) ) . rejects . toThrow (
44
- 'Unsupported config value in test /fixtures/analysis/background-schedule.ts',
45
- )
43
+ await expect (
44
+ extractConfigFromFile ( resolve ( __dirname , '.. /fixtures/analysis/background-schedule.ts') , process . cwd ( ) ) ,
45
+ ) . rejects . toThrow ( 'Unsupported config value in test/fixtures/analysis/background-schedule.ts' )
46
46
expect ( console . error ) . toHaveBeenCalledWith (
47
47
`Invalid config value in test/fixtures/analysis/background-schedule.ts: schedule is not allowed unless type is "experimental-scheduled"` ,
48
48
)
49
49
} )
50
50
it ( 'should throw if schedule is provided when type is default' , async ( ) => {
51
- await expect ( extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/default-schedule.ts' ) ) ) . rejects . toThrow (
52
- 'Unsupported config value in test /fixtures/analysis/default-schedule.ts',
53
- )
51
+ await expect (
52
+ extractConfigFromFile ( resolve ( __dirname , '.. /fixtures/analysis/default-schedule.ts') , process . cwd ( ) ) ,
53
+ ) . rejects . toThrow ( 'Unsupported config value in test/fixtures/analysis/default-schedule.ts' )
54
54
expect ( console . error ) . toHaveBeenCalledWith (
55
55
`Invalid config value in test/fixtures/analysis/default-schedule.ts: schedule is not allowed unless type is "experimental-scheduled"` ,
56
56
)
57
57
} )
58
58
it ( 'should throw if schedule is not provided when type is scheduled' , async ( ) => {
59
- await expect ( extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/missing-schedule.ts' ) ) ) . rejects . toThrow (
60
- 'Unsupported config value in test /fixtures/analysis/missing-schedule.ts',
61
- )
59
+ await expect (
60
+ extractConfigFromFile ( resolve ( __dirname , '.. /fixtures/analysis/missing-schedule.ts') , process . cwd ( ) ) ,
61
+ ) . rejects . toThrow ( 'Unsupported config value in test/fixtures/analysis/missing-schedule.ts' )
62
62
expect ( console . error ) . toHaveBeenCalledWith (
63
63
`Invalid config value in test/fixtures/analysis/missing-schedule.ts: schedule is required when type is "experimental-scheduled"` ,
64
64
)
65
65
} )
66
66
it ( 'should throw if edge runtime is specified for scheduled functions' , async ( ) => {
67
- await expect ( extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/scheduled-edge.ts' ) ) ) . rejects . toThrow (
68
- 'Unsupported config value in test /fixtures/analysis/scheduled-edge.ts',
69
- )
67
+ await expect (
68
+ extractConfigFromFile ( resolve ( __dirname , '.. /fixtures/analysis/scheduled-edge.ts') , process . cwd ( ) ) ,
69
+ ) . rejects . toThrow ( 'Unsupported config value in test/fixtures/analysis/scheduled-edge.ts' )
70
70
expect ( console . error ) . toHaveBeenCalledWith (
71
71
`Invalid config value in test/fixtures/analysis/scheduled-edge.ts: edge runtime is not supported for scheduled functions` ,
72
72
)
73
73
} )
74
74
it ( 'should throw if edge runtime is specified for background functions' , async ( ) => {
75
- await expect ( extractConfigFromFile ( resolve ( __dirname , '../fixtures/analysis/background-edge.ts' ) ) ) . rejects . toThrow (
76
- 'Unsupported config value in test /fixtures/analysis/background-edge.ts',
77
- )
75
+ await expect (
76
+ extractConfigFromFile ( resolve ( __dirname , '.. /fixtures/analysis/background-edge.ts') , process . cwd ( ) ) ,
77
+ ) . rejects . toThrow ( 'Unsupported config value in test/fixtures/analysis/background-edge.ts' )
78
78
expect ( console . error ) . toHaveBeenCalledWith (
79
79
`Invalid config value in test/fixtures/analysis/background-edge.ts: edge runtime is not supported for background functions` ,
80
80
)
0 commit comments