Skip to content

Commit 4fcd3ae

Browse files
authored
automatically start server for jest (github#26206)
* reinstate * start server manually * routing tests too * skip more * sleep more and fail if not 200 * use e2etest for content/ too * automatically start server for jest * does this work? * feedbacked * rename things * getting it to work * add dev dependency * install the right version * don't need to start that * fix package lock * update readme about it * feedbacked
1 parent c050d0f commit 4fcd3ae

File tree

13 files changed

+430
-288
lines changed

13 files changed

+430
-288
lines changed

.github/workflows/browser-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@ jobs:
5959
path: .next/cache
6060
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
6161

62+
- name: Run build script
63+
run: npm run build
64+
6265
- name: Run browser-test
6366
run: npm run browser-test

.github/workflows/test.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,6 @@ jobs:
140140
NODE_ENV: test
141141
run: ./script/warm-before-tests.mjs
142142

143-
- name: Start production-like server in the background
144-
if: ${{ matrix.test-group == 'rendering' || matrix.test-group == 'routing' || matrix.test-group == 'content' }}
145-
env:
146-
NODE_ENV: test
147-
PORT: 4000
148-
run: |
149-
node server.mjs &
150-
sleep 3
151-
curl --retry-connrefused --retry 5 -I --fail http://localhost:4000/healthz
152-
153143
- name: Run tests
154144
env:
155145
DIFF_FILE: get_diff_files.txt

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ COPY --chown=node:node feature-flags.json ./
8989
COPY --chown=node:node data ./data
9090
COPY --chown=node:node next.config.js ./
9191
COPY --chown=node:node server.mjs ./server.mjs
92+
COPY --chown=node:node start-server.mjs ./start-server.mjs
9293

9394
EXPOSE $PORT
9495

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ module.exports = {
4141
],
4242
testMatch: ['**/tests/**/*.js'],
4343
testLocationInResults: isActions,
44+
globalSetup: './script/start-server-for-jest.mjs',
45+
globalTeardown: './script/kill-server-for-jest.mjs',
4446
}

0 commit comments

Comments
 (0)