From be03a1d17bf8aa16cae3c0658ad553ae93fd1ef6 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 15 Nov 2021 12:46:12 -0600 Subject: [PATCH] Remove .only and ensure jest lint rules apply for all tests (#31456) --- .eslintrc.json | 5 +- .../basic/styled-components-disabled.test.ts | 1 + test/integration/i18n-support/test/shared.js | 2 +- .../production-swcminify/test/security.js | 54 ------------------- test/integration/production/test/security.js | 54 ------------------- .../test/css.js | 14 ++--- .../required-server-files-i18n.test.ts | 2 +- 7 files changed, 13 insertions(+), 119 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1cee5507a590152..26824c94ba6675d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,14 +30,15 @@ }, "overrides": [ { - "files": ["test/**/*.test.js"], + "files": ["test/**/*.js", "test/**/*.ts", "**/*.test.ts"], "extends": ["plugin:jest/recommended"], "rules": { "jest/expect-expect": "off", "jest/no-disabled-tests": "off", "jest/no-conditional-expect": "off", "jest/valid-title": "off", - "jest/no-interpolation-in-snapshots": "off" + "jest/no-interpolation-in-snapshots": "off", + "jest/no-export": "off" } }, { "files": ["**/__tests__/**"], "env": { "jest": true } }, diff --git a/test/development/basic/styled-components-disabled.test.ts b/test/development/basic/styled-components-disabled.test.ts index af49dd5deb910d4..3e96e2081e5c51c 100644 --- a/test/development/basic/styled-components-disabled.test.ts +++ b/test/development/basic/styled-components-disabled.test.ts @@ -54,6 +54,7 @@ describe('styled-components SWC transform', () => { throw new Error('did not find mismatch') } catch (err) { // Verify that it really has the logs + // eslint-disable-next-line jest/no-try-expect expect(await matchLogs$(browser)).toBe(true) } } finally { diff --git a/test/integration/i18n-support/test/shared.js b/test/integration/i18n-support/test/shared.js index b76143614412e7e..f24c92461b060d0 100644 --- a/test/integration/i18n-support/test/shared.js +++ b/test/integration/i18n-support/test/shared.js @@ -36,7 +36,7 @@ async function addDefaultLocaleCookie(browser) { export function runTests(ctx) { if (ctx.basePath) { - it.only('should handle basePath like pathname', async () => { + it('should handle basePath like pathname', async () => { const { basePath } = ctx for (const pathname of [ diff --git a/test/integration/production-swcminify/test/security.js b/test/integration/production-swcminify/test/security.js index fd674399249bf57..5d1c2f880a58971 100644 --- a/test/integration/production-swcminify/test/security.js +++ b/test/integration/production-swcminify/test/security.js @@ -291,60 +291,6 @@ module.exports = (context) => { expect(hostname).not.toBe('example.com') }) - it('should handle encoded value in the pathname correctly /', async () => { - const res = await fetchViaHTTP( - context.appPort, - '/redirect/me/to-about/%2fgoogle.com', - undefined, - { - redirect: 'manual', - } - ) - - const { pathname, hostname } = url.parse( - res.headers.get('location') || '' - ) - expect(res.status).toBe(307) - expect(pathname).toBe('/%2fgoogle.com/about') - expect(hostname).not.toBe('google.com') - }) - - it('should handle encoded value in the pathname to query correctly (/)', async () => { - const res = await fetchViaHTTP( - context.appPort, - '/redirect-query-test/%2Fgoogle.com', - undefined, - { - redirect: 'manual', - } - ) - - const { pathname, hostname, query } = url.parse( - res.headers.get('location') || '' - ) - expect(res.status).toBe(307) - expect(pathname).toBe('/about') - expect(query).toBe('foo=%2Fgoogle.com') - expect(hostname).not.toBe('google.com') - expect(hostname).not.toMatch(/google/) - }) - - it('should handle encoded / value for trailing slash correctly', async () => { - const res = await fetchViaHTTP( - context.appPort, - '/%2fexample.com/', - undefined, - { redirect: 'manual' } - ) - - const { pathname, hostname } = url.parse( - res.headers.get('location') || '' - ) - expect(res.status).toBe(308) - expect(pathname).toBe('/%2fexample.com') - expect(hostname).not.toBe('example.com') - }) - if (browserName !== 'internet explorer') { it('should not execute script embedded inside svg image', async () => { let browser diff --git a/test/integration/production/test/security.js b/test/integration/production/test/security.js index fd674399249bf57..5d1c2f880a58971 100644 --- a/test/integration/production/test/security.js +++ b/test/integration/production/test/security.js @@ -291,60 +291,6 @@ module.exports = (context) => { expect(hostname).not.toBe('example.com') }) - it('should handle encoded value in the pathname correctly /', async () => { - const res = await fetchViaHTTP( - context.appPort, - '/redirect/me/to-about/%2fgoogle.com', - undefined, - { - redirect: 'manual', - } - ) - - const { pathname, hostname } = url.parse( - res.headers.get('location') || '' - ) - expect(res.status).toBe(307) - expect(pathname).toBe('/%2fgoogle.com/about') - expect(hostname).not.toBe('google.com') - }) - - it('should handle encoded value in the pathname to query correctly (/)', async () => { - const res = await fetchViaHTTP( - context.appPort, - '/redirect-query-test/%2Fgoogle.com', - undefined, - { - redirect: 'manual', - } - ) - - const { pathname, hostname, query } = url.parse( - res.headers.get('location') || '' - ) - expect(res.status).toBe(307) - expect(pathname).toBe('/about') - expect(query).toBe('foo=%2Fgoogle.com') - expect(hostname).not.toBe('google.com') - expect(hostname).not.toMatch(/google/) - }) - - it('should handle encoded / value for trailing slash correctly', async () => { - const res = await fetchViaHTTP( - context.appPort, - '/%2fexample.com/', - undefined, - { redirect: 'manual' } - ) - - const { pathname, hostname } = url.parse( - res.headers.get('location') || '' - ) - expect(res.status).toBe(308) - expect(pathname).toBe('/%2fexample.com') - expect(hostname).not.toBe('example.com') - }) - if (browserName !== 'internet explorer') { it('should not execute script embedded inside svg image', async () => { let browser diff --git a/test/integration/react-streaming-and-server-components/test/css.js b/test/integration/react-streaming-and-server-components/test/css.js index 141e88a7a8328fc..f2cf95d9af075d5 100644 --- a/test/integration/react-streaming-and-server-components/test/css.js +++ b/test/integration/react-streaming-and-server-components/test/css.js @@ -17,11 +17,11 @@ export default function (context) { expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`) }) // TODO: fix this test - // it.skip('should include css modules with `serverComponents: true`', async () => { - // const browser = await webdriver(context.appPort, '/css-modules') - // const currentColor = await browser.eval( - // `window.getComputedStyle(document.querySelector('h1')).color` - // ) - // expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`) - // }) + it.skip('should include css modules with `serverComponents: true`', async () => { + const browser = await webdriver(context.appPort, '/css-modules') + const currentColor = await browser.eval( + `window.getComputedStyle(document.querySelector('h1')).color` + ) + expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`) + }) } diff --git a/test/production/required-server-files-i18n.test.ts b/test/production/required-server-files-i18n.test.ts index 6285ccfb69a7590..b9b311108f8253e 100644 --- a/test/production/required-server-files-i18n.test.ts +++ b/test/production/required-server-files-i18n.test.ts @@ -701,7 +701,7 @@ describe('should set-up next', () => { expect(JSON.parse($('#router').text()).locale).toBe('en') }) - it('should have the correct asPath for fallback page', async () => { + it('should have the correct asPath for fallback page locale', async () => { const res = await fetchViaHTTP(appPort, '/fr/fallback/[slug]', undefined, { headers: { 'x-matched-path': '/fr/fallback/[slug]',