Skip to content

Commit

Permalink
automatically start server for jest (github#26206)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
peterbe authored Mar 18, 2022
1 parent c050d0f commit 4fcd3ae
Show file tree
Hide file tree
Showing 13 changed files with 430 additions and 288 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/browser-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@ jobs:
path: .next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}

- name: Run build script
run: npm run build

- name: Run browser-test
run: npm run browser-test
10 changes: 0 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,6 @@ jobs:
NODE_ENV: test
run: ./script/warm-before-tests.mjs

- name: Start production-like server in the background
if: ${{ matrix.test-group == 'rendering' || matrix.test-group == 'routing' || matrix.test-group == 'content' }}
env:
NODE_ENV: test
PORT: 4000
run: |
node server.mjs &
sleep 3
curl --retry-connrefused --retry 5 -I --fail http://localhost:4000/healthz
- name: Run tests
env:
DIFF_FILE: get_diff_files.txt
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ COPY --chown=node:node feature-flags.json ./
COPY --chown=node:node data ./data
COPY --chown=node:node next.config.js ./
COPY --chown=node:node server.mjs ./server.mjs
COPY --chown=node:node start-server.mjs ./start-server.mjs

EXPOSE $PORT

Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ module.exports = {
],
testMatch: ['**/tests/**/*.js'],
testLocationInResults: isActions,
globalSetup: './script/start-server-for-jest.mjs',
globalTeardown: './script/kill-server-for-jest.mjs',
}
Loading

0 comments on commit 4fcd3ae

Please sign in to comment.