File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
examples/create-react-app
packages/jest-environment-puppeteer/src Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 12
12
"build" : " react-scripts build" ,
13
13
"test" : " react-scripts test --env=jsdom" ,
14
14
"test:integration" : " jest -c integration/jest.config.js" ,
15
+ "test:integrationWithWatch" : " jest -c integration/jest.config.js --watch" ,
15
16
"eject" : " react-scripts eject"
16
17
},
17
18
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import readConfig from './readConfig'
11
11
12
12
let browser
13
13
14
- export async function setup ( ) {
14
+ export async function setup ( jestConfig ) {
15
15
const config = await readConfig ( )
16
16
if ( config . connect ) {
17
17
browser = await puppeteer . connect ( config . connect )
@@ -20,6 +20,8 @@ export async function setup() {
20
20
}
21
21
process . env . PUPPETEER_WS_ENDPOINT = browser . wsEndpoint ( )
22
22
23
+ if ( jestConfig . watch || jestConfig . watchAll ) return
24
+
23
25
if ( config . server ) {
24
26
try {
25
27
await setupServer ( config . server )
@@ -49,13 +51,15 @@ export async function setup() {
49
51
}
50
52
}
51
53
52
- export async function teardown ( ) {
53
- await teardownServer ( )
54
-
55
- const config = await readConfig ( )
56
- if ( config . connect ) {
57
- await browser . disconnect ( ) ;
58
- } else {
59
- await browser . close ( )
54
+ export async function teardown ( jestConfig ) {
55
+ if ( ! jestConfig . watch && ! jestConfig . watchAll ) {
56
+ await teardownServer ( )
57
+
58
+ const config = await readConfig ( )
59
+ if ( config . connect ) {
60
+ await browser . disconnect ( )
61
+ } else {
62
+ await browser . close ( )
63
+ }
60
64
}
61
65
}
You can’t perform that action at this time.
0 commit comments