This repository was archived by the owner on Apr 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +493
-129
lines changed Expand file tree Collapse file tree 9 files changed +493
-129
lines changed Original file line number Diff line number Diff line change
1
+ .wrangler
Original file line number Diff line number Diff line change @@ -46,11 +46,8 @@ function setRestClientRetryTime(time: number) {
46
46
47
47
/* eslint-disable-next-line import/no-anonymous-default-export */
48
48
export default {
49
- async fetch ( req : any , _env : any , _ctx : any ) {
50
- const apiServerPort : number = parseInt (
51
- ( globalThis as any ) . HTTP_SERVER_PORT || '3000' ,
52
- 10 ,
53
- ) ;
49
+ async fetch ( req : any , env : any , _ctx : any ) {
50
+ const apiServerPort : number = parseInt ( env . HTTP_SERVER_PORT || '3000' , 10 ) ;
54
51
const apiServer = `localhost:${ apiServerPort } ` ;
55
52
const client = new RestClient ( {
56
53
session : new Session ( { ...session , shop : apiServer } ) ,
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ function allEnvironmentsReady(environments: E2eTestEnvironment[]): boolean {
32
32
export async function runEnvironments (
33
33
environments : E2eTestEnvironment [ ] ,
34
34
) : Promise < boolean > {
35
+ // Give enough time for the servers to start listening
36
+ await sleep ( 2000 ) ;
37
+
35
38
const maxAttempts = 5 ;
36
39
37
40
if ( allEnvironmentsReady ( environments ) ) return true ;
Original file line number Diff line number Diff line change 1
1
import { spawn } from 'child_process' ;
2
+ import path from 'path' ;
2
3
3
4
import '..' ;
4
5
5
6
import '../../../runtime/__tests__/all.test' ;
6
7
import { runTests , E2eTestEnvironment } from '../../__e2etests__/e2e-runner.test' ;
7
8
8
9
const cfWorkerAppPort = '7777' ;
10
+ // This value must match the one in ./wrangler.toml
9
11
const dummyServerPort = '7778' ;
10
12
11
13
const workerEnvironment : E2eTestEnvironment = {
@@ -15,12 +17,14 @@ const workerEnvironment: E2eTestEnvironment = {
15
17
process : spawn (
16
18
'yarn' ,
17
19
[
18
- 'miniflare' ,
19
- '--global' ,
20
- `HTTP_SERVER_PORT=${ dummyServerPort } ` ,
20
+ 'wrangler' ,
21
+ 'dev' ,
22
+ '-c' ,
23
+ path . join ( __dirname , './wrangler.toml' ) ,
21
24
'--port' ,
22
25
`${ cfWorkerAppPort } ` ,
23
- '--modules' ,
26
+ '--inspector-port' ,
27
+ '9249' ,
24
28
'bundle/test-web-api-app.js' ,
25
29
] ,
26
30
{
Original file line number Diff line number Diff line change
1
+ name =" test_cf_worker"
2
+ compatibility_date =" 2024-01-22"
3
+
4
+ send_metrics =false
5
+
6
+ [vars ]
7
+ HTTP_SERVER_PORT =7778
Original file line number Diff line number Diff line change 1
1
import { spawn } from 'child_process' ;
2
+ import path from 'path' ;
2
3
3
4
import '..' ;
4
5
5
6
import '../../../runtime/__tests__/all.test' ;
6
7
import { runTests , E2eTestEnvironment } from '../../__e2etests__/e2e-runner.test' ;
7
8
8
9
const webApiAppPort = '8888' ;
10
+ // This value must match the one in ./wrangler.toml
9
11
const dummyServerPort = '8889' ;
10
12
11
13
// We should also try running this on a different environment that implements the Web API for better coverage.
@@ -16,12 +18,14 @@ const webApiEnvironment: E2eTestEnvironment = {
16
18
process : spawn (
17
19
'yarn' ,
18
20
[
19
- 'miniflare' ,
20
- '--global' ,
21
- `HTTP_SERVER_PORT=${ dummyServerPort } ` ,
21
+ 'wrangler' ,
22
+ 'dev' ,
23
+ '-c' ,
24
+ path . join ( __dirname , './wrangler.toml' ) ,
22
25
'--port' ,
23
26
`${ webApiAppPort } ` ,
24
- '--modules' ,
27
+ '--inspector-port' ,
28
+ '9259' ,
25
29
'bundle/test-web-api-app.js' ,
26
30
] ,
27
31
{
Original file line number Diff line number Diff line change
1
+ name =" test_web_api"
2
+ compatibility_date =" 2024-01-22"
3
+
4
+ send_metrics =false
5
+
6
+ [vars ]
7
+ HTTP_SERVER_PORT =8889
Original file line number Diff line number Diff line change 90
90
"@types/uuid" : " ^9.0.0" ,
91
91
"express" : " ^4.17.13" ,
92
92
"jest-environment-miniflare" : " ^2.12.1" ,
93
- "miniflare" : " ^2.6.0 " ,
93
+ "miniflare" : " ^3.20231218.2 " ,
94
94
"rollup" : " ^2.79.1" ,
95
95
"rollup-plugin-swc" : " ^0.2.1" ,
96
- "supertest" : " ^6.1.3"
96
+ "supertest" : " ^6.1.3" ,
97
+ "wrangler" : " ^3.24.0"
97
98
},
98
99
"files" : [
99
100
" **/*.d.ts" ,
You can’t perform that action at this time.
0 commit comments