Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove .only and ensure jest lint rules apply for all tests #31456

Merged
merged 1 commit into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions .eslintrc.json
Expand Up @@ -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 } },
Expand Down
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/i18n-support/test/shared.js
Expand Up @@ -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 [
Expand Down
54 changes: 0 additions & 54 deletions test/integration/production-swcminify/test/security.js
Expand Up @@ -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
Expand Down
54 changes: 0 additions & 54 deletions test/integration/production/test/security.js
Expand Up @@ -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
Expand Down
Expand Up @@ -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)"`)
})
}
2 changes: 1 addition & 1 deletion test/production/required-server-files-i18n.test.ts
Expand Up @@ -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]',
Expand Down