Skip to content

Commit e02c2b7

Browse files
authored
chore: add the Next.js e2e test suite (#1782)
* chore: all the tests * chore: fix eslint * chore: parallelise e2e tests * chore: don't fail fast * chore: unignore modules and use node-fetch * chore: very parallel * chore: don't mock fetch 🤦 * chore: remove disabled tests * chore: test with node 18 * chore: switchable fetch * chore: remove irrelevant tests * chore: remove disabled test * chore: add reporter * chore: no concurrency * chore: try to fix jest * chore: fix test command * chore: artifact file path * chore: use site build command * chore: download artifacts * chore: report per-chunk * chore: update syntax * chore: report to summary * chore: do annotate * chore: update and add summary * chore: rearrange * chore: combine tests * chore: fix test * chore: rearrange and disable failing suites * chore: skip broken ntl and fail faster * chore: disable suite * chore: skip failing tests * chore: add ability to run disabled tests * chore: add comments to workflow file * chore: one worker per file * chore: oops * chore: make path relative to test dir * chore: conditionally skip * chore: enable middleware-responses test * chore: run all tests once * chore: don't run disabled tests * fix: ensure responses are Responses * chore: re-enable test * chore: run all tests * chore: enable another suite * fix: better headers.getAll polyfill * chore: enable middleware-redirects suite * chore: conditionally enable req body tests * chore: disable failing tests * chore: add test readme doc * chore: remove eslint changes
1 parent 637dd1b commit e02c2b7

File tree

201 files changed

+7903
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+7903
-223
lines changed

.github/workflows/e2e-next.yml

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,77 @@ on:
66
branches: [main]
77

88
jobs:
9+
setup:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
test-files: ${{ steps['set-test-files'].outputs['test-files'] }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- run: npm install
16+
- id: set-test-files
17+
name: Get test files
18+
# Extracts the list of all test files as JSON and trims to be relative to the test dir to be easier to read
19+
run:
20+
echo "test-files=$(npx jest -c test/e2e/jest.config.js --listTests --json | jq -cM 'map(.[env.PWD | length +
21+
10:])')" >> $GITHUB_OUTPUT
22+
# echo "test-files=$(npx jest -c test/e2e/jest.config.all.js --listTests --json | jq -cM 'map(.[env.PWD | length
23+
# + 10:])')" >> $GITHUB_OUTPUT
24+
925
test:
10-
name: E2E tests
1126
runs-on: ubuntu-latest
27+
name: test (${{ matrix.test-file }})
28+
needs:
29+
- setup
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
# Creates a job for each chunk ID. This will be assigned one or more test files to run
34+
test-file: ${{ fromJson(needs.setup.outputs['test-files']) }}
1235
steps:
13-
- uses: actions/checkout@v2
14-
- name: Installing with LTS Node.js
15-
uses: actions/setup-node@v2
16-
with:
17-
node-version: 'lts/*'
18-
- name: NPM Install
19-
run: npm install
20-
- name: Run Next.js e2e test suite
21-
run: npm run test:next
36+
- uses: actions/checkout@v3
37+
- run: npm install
38+
- name: Run tests
39+
run: npx jest --reporters=jest-junit --reporters=default -c test/e2e/jest.config.all.js ${{ matrix.test-file }}
2240
env:
2341
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_BOT_AUTH_TOKEN }}
2442
NETLIFY_SITE_ID: 1d5a5c76-d445-4ae5-b694-b0d3f2e2c395
43+
# RUN_SKIPPED_TESTS: true
44+
# - uses: phoenix-actions/test-reporting@v10
45+
# if: ${{ always() }}
46+
# name: Report Test Results
47+
# # Generates annotations for the test failures
48+
# id: test-report
49+
# with:
50+
# name: E2E Test chunk ${{ matrix.chunk }}
51+
# path: 'reports/**/*.xml' # Path to test results (inside artifact .zip)
52+
# output-to: 'checks'
53+
# max-annotations: 49 # Maximum number of annotations to be created
54+
# reporter: jest-junit # Format of test results
55+
56+
- uses: actions/upload-artifact@v3
57+
# upload test results
58+
if: ${{ always() }}
59+
name: Upload test results
60+
with:
61+
name: test-results
62+
path: reports/jest-*.xml
63+
report:
64+
runs-on: ubuntu-latest
65+
if: ${{ always() }}
66+
needs:
67+
- test
68+
steps:
69+
- uses: actions/checkout@v3
70+
- uses: actions/download-artifact@v3
71+
with:
72+
path: reports
73+
- name: Combine reports
74+
# The test reporter can handle multiple files, but these have random filenames so the output is better when combined
75+
run: npx junit-report-merger test-results.xml reports/**/*.xml
76+
- uses: phoenix-actions/test-reporting@v10
77+
with:
78+
name: Jest Tests
79+
output-to: 'step-summary'
80+
path: 'test-results.xml'
81+
max-annotations: 49
82+
reporter: jest-junit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,6 @@ packages/*/lib
150150

151151
# Cypress
152152
cypress/screenshots
153+
154+
# Test cases have node module fixtures
155+
!test/**/node_modules

0 commit comments

Comments
 (0)