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

Refactor more tests to createNextDescribe #44104

Merged
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: 0 additions & 5 deletions test/development/acceptance-app/ReactRefresh.test.ts
Expand Up @@ -5,11 +5,6 @@ import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'

describe('ReactRefresh app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
Expand Up @@ -5,11 +5,6 @@ import path from 'path'

// TODO-APP: Investigate snapshot mismatch
describe('ReactRefreshLogBox app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
Expand Up @@ -7,11 +7,6 @@ import path from 'path'
// TODO: figure out why snapshots mismatch on GitHub actions
// specifically but work in docker and locally
describe.skip('ReactRefreshLogBox app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
5 changes: 0 additions & 5 deletions test/development/acceptance-app/ReactRefreshLogBox.test.ts
Expand Up @@ -6,11 +6,6 @@ import { check } from 'next-test-utils'
import path from 'path'

describe('ReactRefreshLogBox app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
Expand Up @@ -6,11 +6,6 @@ import path from 'path'
// TODO: re-enable these tests after figuring out what is causing
// them to be so unreliable in CI
describe.skip('ReactRefreshLogBox app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
5 changes: 0 additions & 5 deletions test/development/acceptance-app/ReactRefreshModule.test.ts
Expand Up @@ -4,11 +4,6 @@ import { NextInstance } from 'test/lib/next-modes/base'
import { sandbox } from './helpers'

describe('ReactRefreshModule app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
Expand Up @@ -5,11 +5,6 @@ import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'

describe('ReactRefreshRegression app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
5 changes: 0 additions & 5 deletions test/development/acceptance-app/server-components.test.ts
Expand Up @@ -6,11 +6,6 @@ import path from 'path'
import { check } from 'next-test-utils'

describe('Error Overlay for server components', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
Expand Down
6 changes: 1 addition & 5 deletions test/development/basic-basepath/hmr.test.ts
Expand Up @@ -532,14 +532,10 @@ describe('basic HMR', () => {
)
)

const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17'

expect(await hasRedbox(browser)).toBe(true)
// TODO: Replace this when webpack 5 is the default
expect(await getRedboxHeader(browser)).toMatch(
`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.`
`Objects are not valid as a React child (found: [object RegExp]). If you meant to render a collection of children, use an array instead.`
)

await next.patchFile(aboutPage, aboutContent)
Expand Down
6 changes: 1 addition & 5 deletions test/development/basic/hmr.test.ts
Expand Up @@ -597,14 +597,10 @@ describe('basic HMR', () => {
)
)

const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17'

expect(await hasRedbox(browser)).toBe(true)
// TODO: Replace this when webpack 5 is the default
expect(await getRedboxHeader(browser)).toMatch(
`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.`
`Objects are not valid as a React child (found: [object RegExp]). If you meant to render a collection of children, use an array instead.`
)

await next.patchFile(aboutPage, aboutContent)
Expand Down
87 changes: 38 additions & 49 deletions test/e2e/app-dir/app-alias.test.ts
@@ -1,56 +1,45 @@
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'
import webdriver from 'next-webdriver'
import { createNextDescribe } from 'e2e-utils'
import path from 'path'
import { readJSON } from 'fs-extra'

describe('app-dir alias handling', () => {
if ((global as any).isNextDeploy) {
it('should skip next deploy for now', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: new FileRef(path.join(__dirname, 'app-alias')),
dependencies: {
react: 'latest',
'react-dom': 'latest',
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
},
packageJson: {
type: 'module',
},
createNextDescribe(
'app-dir alias handling',
{
files: path.join(__dirname, 'app-alias'),
dependencies: {
react: 'latest',
'react-dom': 'latest',
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
},
packageJson: {
type: 'module',
},
skipDeployment: true,
},
({ next, isNextDev }) => {
it('should handle typescript paths alias correctly', async () => {
const html = await next.render('/button')
expect(html).toContain('click</button>')
})
})
afterAll(() => next.destroy())

it('should handle typescript paths alias correctly', async () => {
const html = await renderViaHTTP(next.url, '/button')
expect(html).toContain('click</button>')
})

it('should resolve css imports from outside with src folder presented', async () => {
const browser = await webdriver(next.url, '/button')
const fontSize = await browser
.elementByCss('button')
.getComputedCss('font-size')
expect(fontSize).toBe('50px')
})
it('should resolve css imports from outside with src folder presented', async () => {
const browser = await next.browser('/button')
const fontSize = await browser
.elementByCss('button')
.getComputedCss('font-size')
expect(fontSize).toBe('50px')
})

if (!(global as any).isNextDev) {
it('should generate app-build-manifest correctly', async () => {
// Remove other page CSS files:
const manifest = await readJSON(
path.join(next.testDir, '.next', 'app-build-manifest.json')
)
if (!isNextDev) {
it('should generate app-build-manifest correctly', async () => {
// Remove other page CSS files:
const manifest = await next.readJSON(
path.join('.next', 'app-build-manifest.json')
)

expect(manifest.pages).not.toBeEmptyObject()
})
expect(manifest.pages).not.toBeEmptyObject()
})
}
}
})
)
49 changes: 20 additions & 29 deletions test/e2e/app-dir/app-edge-global.test.ts
@@ -1,32 +1,23 @@
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'
import { createNextDescribe } from 'e2e-utils'
import path from 'path'

describe('app-dir global edge configuration', () => {
if ((global as any).isNextDeploy) {
it('should skip next deploy for now', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: new FileRef(path.join(__dirname, 'app-edge-global')),
dependencies: {
react: 'latest',
'react-dom': 'latest',
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
},
createNextDescribe(
'app-dir global edge configuration',
{
files: path.join(__dirname, 'app-edge-global'),
dependencies: {
react: 'latest',
'react-dom': 'latest',
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
},
skipDeployment: true,
},
({ next }) => {
it('should handle edge only routes', async () => {
const html = await next.render('/app-edge')
expect(html).toContain('<p>Edge!</p>')
})
})
afterAll(() => next.destroy())

it('should handle edge only routes', async () => {
const appHtml = await renderViaHTTP(next.url, '/app-edge')
expect(appHtml).toContain('<p>Edge!</p>')
})
})
}
)