Unverified Commit e148d2bd authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Continue testing react v17 with e2e tests (#35787)

* Continue testing react v17 with e2e tests

* update react 17 expected error

* Update env variable name and add log

* fix starter cache version

* remove extra setup condition

* Revert "remove extra setup condition"

This reverts commit 5760a9f8867213f95a9fac073fe27a9ec01b780f.

* update basepath test

* remove log

* stabilize test
parent 6a1e8db7
...@@ -255,6 +255,57 @@ jobs: ...@@ -255,6 +255,57 @@ jobs:
path: | path: |
test/traces test/traces
testDevReact17:
name: Test Development (react v17)
runs-on: ubuntu-latest
needs: [build, build-native-test]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
NEXT_TEST_REACT_VERSION: ^17
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 16
- run: echo ${{needs.build.outputs.docsChange}}
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}
- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-test-binary
path: packages/next-swc/native
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- run: node run-tests.js --type development
name: Run test/development
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- name: Upload test trace
if: always()
uses: actions/upload-artifact@v2
with:
name: test-trace
if-no-files-found: ignore
retention-days: 2
path: |
test/traces
testDevE2E: testDevE2E:
name: Test Development (E2E) name: Test Development (E2E)
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -309,6 +360,57 @@ jobs: ...@@ -309,6 +360,57 @@ jobs:
path: | path: |
test/traces test/traces
testDevE2EReact17:
name: Test Development (E2E) (react v17)
runs-on: ubuntu-latest
needs: [build, build-native-test]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
NEXT_TEST_REACT_VERSION: ^17
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 16
- run: echo ${{needs.build.outputs.docsChange}}
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}
- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-test-binary
path: packages/next-swc/native
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- run: NEXT_TEST_MODE=dev node run-tests.js --type e2e
name: Run test/e2e (dev)
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- name: Upload test trace
if: always()
uses: actions/upload-artifact@v2
with:
name: test-trace
if-no-files-found: ignore
retention-days: 2
path: |
test/traces
testProd: testProd:
name: Test Production name: Test Production
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -353,6 +455,47 @@ jobs: ...@@ -353,6 +455,47 @@ jobs:
name: Run test/production name: Run test/production
if: ${{needs.build.outputs.docsChange != 'docs only change'}} if: ${{needs.build.outputs.docsChange != 'docs only change'}}
testProdReact17:
name: Test Production (react v17)
runs-on: ubuntu-latest
needs: [build, build-native-test]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
NEXT_TEST_REACT_VERSION: ^17
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 16
- run: echo ${{needs.build.outputs.docsChange}}
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}
- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-test-binary
path: packages/next-swc/native
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- run: node run-tests.js --type production
name: Run test/production
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
testProdE2E: testProdE2E:
name: Test Production (E2E) name: Test Production (E2E)
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -397,6 +540,47 @@ jobs: ...@@ -397,6 +540,47 @@ jobs:
name: Run test/e2e (production) name: Run test/e2e (production)
if: ${{needs.build.outputs.docsChange != 'docs only change'}} if: ${{needs.build.outputs.docsChange != 'docs only change'}}
testProdE2EReact17:
name: Test Production (E2E) (react v17)
runs-on: ubuntu-latest
needs: [build, build-native-test]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
NEXT_TEST_REACT_VERSION: ^17
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: ${{ matrix.node }}
- run: echo ${{needs.build.outputs.docsChange}}
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}
- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-test-binary
path: packages/next-swc/native
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
- run: NEXT_TEST_MODE=start node run-tests.js --type e2e
name: Run test/e2e (production)
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
testIntegration: testIntegration:
name: Test Integration name: Test Integration
runs-on: ubuntu-latest runs-on: ubuntu-latest
......
...@@ -1024,6 +1024,14 @@ function Root({ ...@@ -1024,6 +1024,14 @@ function Root({
() => callbacks.forEach((callback) => callback()), () => callbacks.forEach((callback) => callback()),
[callbacks] [callbacks]
) )
// We should ask to measure the Web Vitals after rendering completes so we
// don't cause any hydration delay:
React.useEffect(() => {
measureWebVitals(onPerfEntry)
flushBufferedVitalsMetrics()
}, [])
if (process.env.__NEXT_TEST_MODE) { if (process.env.__NEXT_TEST_MODE) {
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => { React.useEffect(() => {
...@@ -1034,13 +1042,6 @@ function Root({ ...@@ -1034,13 +1042,6 @@ function Root({
} }
}, []) }, [])
} }
// We should ask to measure the Web Vitals after rendering completes so we
// don't cause any hydration delay:
React.useEffect(() => {
measureWebVitals(onPerfEntry)
flushBufferedVitalsMetrics()
}, [])
return children as React.ReactElement return children as React.ReactElement
} }
......
...@@ -215,9 +215,10 @@ async function main() { ...@@ -215,9 +215,10 @@ async function main() {
// a starter Next.js install to re-use to speed up tests // a starter Next.js install to re-use to speed up tests
// to avoid having to run yarn each time // to avoid having to run yarn each time
console.log('Creating Next.js install for isolated tests') console.log('Creating Next.js install for isolated tests')
const reactVersion = process.env.NEXT_TEST_REACT_VERSION || 'latest'
const testStarter = await createNextInstall({ const testStarter = await createNextInstall({
react: '17.0.2', react: reactVersion,
'react-dom': '17.0.2', 'react-dom': reactVersion,
}) })
process.env.NEXT_TEST_STARTER = testStarter process.env.NEXT_TEST_STARTER = testStarter
} }
......
...@@ -532,6 +532,8 @@ describe('basic HMR', () => { ...@@ -532,6 +532,8 @@ describe('basic HMR', () => {
) )
) )
const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17'
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
// TODO: Replace this when webpack 5 is the default // TODO: Replace this when webpack 5 is the default
expect( expect(
...@@ -540,7 +542,9 @@ describe('basic HMR', () => { ...@@ -540,7 +542,9 @@ describe('basic HMR', () => {
'Unknown' 'Unknown'
) )
).toMatch( ).toMatch(
'Objects are not valid as a React child (found: /search/). If you meant to render a collection of children, use an array instead.' `Objects are not valid as a React child (found: ${
isReact17 ? '/search/' : '[object RegExp]'
}). If you meant to render a collection of children, use an array instead.`
) )
await next.patchFile(aboutPage, aboutContent) await next.patchFile(aboutPage, aboutContent)
......
...@@ -22,10 +22,6 @@ describe('basic HMR', () => { ...@@ -22,10 +22,6 @@ describe('basic HMR', () => {
pages: new FileRef(join(__dirname, 'hmr/pages')), pages: new FileRef(join(__dirname, 'hmr/pages')),
components: new FileRef(join(__dirname, 'hmr/components')), components: new FileRef(join(__dirname, 'hmr/components')),
}, },
dependencies: {
react: 'latest',
'react-dom': 'latest',
},
}) })
}) })
afterAll(() => next.destroy()) afterAll(() => next.destroy())
...@@ -589,6 +585,8 @@ describe('basic HMR', () => { ...@@ -589,6 +585,8 @@ describe('basic HMR', () => {
) )
) )
const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17'
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
// TODO: Replace this when webpack 5 is the default // TODO: Replace this when webpack 5 is the default
expect( expect(
...@@ -597,7 +595,9 @@ describe('basic HMR', () => { ...@@ -597,7 +595,9 @@ describe('basic HMR', () => {
'Unknown' 'Unknown'
) )
).toMatch( ).toMatch(
'Objects are not valid as a React child (found: [object RegExp]). If you meant to render a collection of children, use an array instead.' `Objects are not valid as a React child (found: ${
isReact17 ? '/search/' : '[object RegExp]'
}). If you meant to render a collection of children, use an array instead.`
) )
await next.patchFile(aboutPage, aboutContent) await next.patchFile(aboutPage, aboutContent)
......
...@@ -17,8 +17,6 @@ describe('styled-components SWC transform', () => { ...@@ -17,8 +17,6 @@ describe('styled-components SWC transform', () => {
}, },
dependencies: { dependencies: {
'styled-components': '5.3.3', 'styled-components': '5.3.3',
react: 'latest',
'react-dom': 'latest',
}, },
}) })
}) })
......
...@@ -739,6 +739,10 @@ describe('basePath', () => { ...@@ -739,6 +739,10 @@ describe('basePath', () => {
it('should use urls with basepath in router events for hash changes', async () => { it('should use urls with basepath in router events for hash changes', async () => {
const browser = await webdriver(next.url, `${basePath}/hello`) const browser = await webdriver(next.url, `${basePath}/hello`)
try { try {
await check(
() => browser.eval('window.next.router.isReady ? "ready" : "no"'),
'ready'
)
await browser.eval('window._clearEventLog()') await browser.eval('window._clearEventLog()')
await browser.elementByCss('#hash-change').click() await browser.elementByCss('#hash-change').click()
...@@ -763,7 +767,12 @@ describe('basePath', () => { ...@@ -763,7 +767,12 @@ describe('basePath', () => {
it('should use urls with basepath in router events for cancelled routes', async () => { it('should use urls with basepath in router events for cancelled routes', async () => {
const browser = await webdriver(next.url, `${basePath}/hello`) const browser = await webdriver(next.url, `${basePath}/hello`)
try { try {
await check(
() => browser.eval('window.next.router.isReady ? "ready" : "no"'),
'ready'
)
await browser.eval('window._clearEventLog()') await browser.eval('window._clearEventLog()')
await browser await browser
.elementByCss('#slow-route') .elementByCss('#slow-route')
.click() .click()
...@@ -793,6 +802,10 @@ describe('basePath', () => { ...@@ -793,6 +802,10 @@ describe('basePath', () => {
it('should use urls with basepath in router events for failed route change', async () => { it('should use urls with basepath in router events for failed route change', async () => {
const browser = await webdriver(next.url, `${basePath}/hello`) const browser = await webdriver(next.url, `${basePath}/hello`)
try { try {
await check(
() => browser.eval('window.next.router.isReady ? "ready" : "no"'),
'ready'
)
await browser.eval('window._clearEventLog()') await browser.eval('window._clearEventLog()')
await browser.elementByCss('#error-route').click() await browser.elementByCss('#error-route').click()
......
...@@ -88,13 +88,15 @@ export class NextInstance { ...@@ -88,13 +88,15 @@ export class NextInstance {
) { ) {
await fs.copy(process.env.NEXT_TEST_STARTER, this.testDir) await fs.copy(process.env.NEXT_TEST_STARTER, this.testDir)
} else if (!skipIsolatedNext) { } else if (!skipIsolatedNext) {
this.testDir = await createNextInstall( const reactVersion = process.env.NEXT_TEST_REACT_VERSION || 'latest'
{ const finalDependencies = {
react: 'latest', react: reactVersion,
'react-dom': 'latest', 'react-dom': reactVersion,
...this.dependencies, ...this.dependencies,
...((this.packageJson.dependencies as object | undefined) || {}), ...((this.packageJson.dependencies as object | undefined) || {}),
}, }
this.testDir = await createNextInstall(
finalDependencies,
this.installCommand, this.installCommand,
this.packageJson this.packageJson
) )
......
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