Unverified Commit 4365463f authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Run tests against node LTS (v16) and current (v17) (#35414)

* Run tests against node LTS (v16) and current (v17)

* update pnp tests
parent bc460229
...@@ -208,12 +208,16 @@ jobs: ...@@ -208,12 +208,16 @@ jobs:
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1 NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps: steps:
- name: Setup node - name: Setup node
uses: actions/setup-node@v2 uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}} if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with: with:
node-version: 14 node-version: ${{ matrix.node }}
- run: echo ${{needs.build.outputs.docsChange}} - run: echo ${{needs.build.outputs.docsChange}}
...@@ -258,12 +262,16 @@ jobs: ...@@ -258,12 +262,16 @@ jobs:
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1 NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps: steps:
- name: Setup node - name: Setup node
uses: actions/setup-node@v2 uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}} if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with: with:
node-version: 14 node-version: ${{ matrix.node }}
- run: echo ${{needs.build.outputs.docsChange}} - run: echo ${{needs.build.outputs.docsChange}}
...@@ -308,12 +316,16 @@ jobs: ...@@ -308,12 +316,16 @@ jobs:
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1 NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps: steps:
- name: Setup node - name: Setup node
uses: actions/setup-node@v2 uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}} if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with: with:
node-version: 14 node-version: ${{ matrix.node }}
- run: echo ${{needs.build.outputs.docsChange}} - run: echo ${{needs.build.outputs.docsChange}}
...@@ -348,12 +360,16 @@ jobs: ...@@ -348,12 +360,16 @@ jobs:
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1 NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps: steps:
- name: Setup node - name: Setup node
uses: actions/setup-node@v2 uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}} if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with: with:
node-version: 14 node-version: ${{ matrix.node }}
- run: echo ${{needs.build.outputs.docsChange}} - run: echo ${{needs.build.outputs.docsChange}}
......
...@@ -7,6 +7,12 @@ import { NextInstance } from 'test/lib/next-modes/base' ...@@ -7,6 +7,12 @@ import { NextInstance } from 'test/lib/next-modes/base'
jest.setTimeout(2 * 60 * 1000) jest.setTimeout(2 * 60 * 1000)
export function runTests(example = '') { export function runTests(example = '') {
const versionParts = process.versions.node.split('.').map((i) => Number(i))
if (
versionParts[0] > 16 ||
(versionParts[0] === 16 && versionParts[1] >= 14)
) {
let next: NextInstance let next: NextInstance
beforeAll(async () => { beforeAll(async () => {
...@@ -31,25 +37,24 @@ export function runTests(example = '') { ...@@ -31,25 +37,24 @@ export function runTests(example = '') {
prev.push(`${cur}@${dependencies[cur]}`) prev.push(`${cur}@${dependencies[cur]}`)
return prev return prev
}, [] as string[]) }, [] as string[])
return `yarn set version 3.1.1 && yarn config set enableGlobalCache true && yarn config set compressionLevel 0 && yarn add ${pkgs.join( return `yarn set version berry && yarn config set enableGlobalCache true && yarn config set compressionLevel 0 && yarn add ${pkgs.join(
' ' ' '
)}` )}`
}, },
buildCommand: `yarn next build --no-lint`, buildCommand: `yarn next build --no-lint`,
startCommand: (global as any).isNextDev ? `yarn next` : `yarn next start`, startCommand: (global as any).isNextDev
? `yarn next`
: `yarn next start`,
}) })
}) })
afterAll(() => next?.destroy()) afterAll(() => next?.destroy())
it('should warn on not fully supported node versions', async () => {
expect(next.cliOutput).toContain(
'Node.js 16.14+ is required for Yarn PnP 3.20+. More info'
)
})
it(`should compile and serve the index page correctly ${example}`, async () => { it(`should compile and serve the index page correctly ${example}`, async () => {
const res = await fetchViaHTTP(next.url, '/') const res = await fetchViaHTTP(next.url, '/')
expect(res.status).toBe(200) expect(res.status).toBe(200)
expect(await res.text()).toContain('<html') expect(await res.text()).toContain('<html')
}) })
} else {
it('should not run PnP test for older node versions', () => {})
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment