Unverified Commit 9b87239c authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

test: unskip tests for Turbopack (#100185)

- Run three more test suites with Turbopack as well
- Delete test/production/typescript-custom-tsconfig. It was only
checking stdout (and not actual behavior), and we have multiple other
tests for `nextConfig.tsconfigPath` anyway: test/e2e/tsconfig-path,
test/e2e/typescript-custom-tsconfig,
test/production/app-dir/typescript-cli
parent 943f3a40
...@@ -2,18 +2,18 @@ import { nextTestSetup } from 'e2e-utils' ...@@ -2,18 +2,18 @@ import { nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Assertions may differ from a local Next.js // TODO(deploy-test-completion): Assertions may differ from a local Next.js
// server when deployed. // server when deployed.
// @force-gate !deploy // @force-gate !deploy
// @force-gate !start || !turbopackDev
describe('API routes', () => { describe('API routes', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
it('should return data when catch-all', async () => { it('should return data when catch-all', async () => {
const data = await next const res = await next.fetch('/api/users/1')
.fetch('/api/users/1', {}) expect(res.status).toBe(200)
.then((res) => res.ok && res.json()) expect(await res.json()).toEqual({
route: 'users',
expect(data).toEqual({ slug: ['1'] }) query: { slug: ['1'] },
})
}) })
it('should return redirect when catch-all with index and trailing slash', async () => { it('should return redirect when catch-all with index and trailing slash', async () => {
...@@ -26,18 +26,14 @@ describe('API routes', () => { ...@@ -26,18 +26,14 @@ describe('API routes', () => {
}) })
it('should return data when catch-all with index and trailing slash', async () => { it('should return data when catch-all with index and trailing slash', async () => {
const data = await next const res = await next.fetch('/api/users/')
.fetch('/api/users/', {}) expect(res.status).toBe(200)
.then((res) => res.ok && res.json()) expect(await res.json()).toEqual({ route: 'users', query: {} })
expect(data).toEqual({})
}) })
it('should return data when catch-all with index and no trailing slash', async () => { it('should return data when catch-all with index and no trailing slash', async () => {
const data = await next const res = await next.fetch('/api/users')
.fetch('/api/users', {}) expect(res.status).toBe(200)
.then((res) => res.ok && res.json()) expect(await res.json()).toEqual({ route: 'users', query: {} })
expect(data).toEqual({})
}) })
}) })
export default function (req, res) { export default function (req, res) {
res.json(req.query) res.json({ route: 'users', query: req.query })
} }
import { isNextDev, nextTestSetup } from 'e2e-utils' import { isNextDev, nextTestSetup } from 'e2e-utils'
import { gate } from 'next-test-utils'
import { join } from 'path' import { join } from 'path'
import stripAnsi from 'strip-ansi' import stripAnsi from 'strip-ansi'
...@@ -6,7 +7,7 @@ const pagePath = 'pages/index.jsx' ...@@ -6,7 +7,7 @@ const pagePath = 'pages/index.jsx'
const apiPath = 'pages/api/edge.js' const apiPath = 'pages/api/edge.js'
// Deploy mode exclusion: This suite mutates fixture files and asserts local build and CLI output. // Deploy mode exclusion: This suite mutates fixture files and asserts local build and CLI output.
// @force-gate !turbopack && !deploy // @force-gate !deploy
describe.each([ describe.each([
{ appDir: join(__dirname, './app/src'), title: 'src/pages and API routes' }, { appDir: join(__dirname, './app/src'), title: 'src/pages and API routes' },
{ appDir: join(__dirname, './app'), title: 'pages and API routes' }, { appDir: join(__dirname, './app'), title: 'pages and API routes' },
...@@ -52,11 +53,17 @@ describe.each([ ...@@ -52,11 +53,17 @@ describe.each([
const res = await next.fetch(`/api/edge`) const res = await next.fetch(`/api/edge`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(next.cliOutput).not.toInclude('error') expect(next.cliOutput).not.toInclude('error')
expect(stripAnsi(next.cliOutput)).toInclude( if (await gate((c) => c.turbopack)) {
`/api/edge provided runtime 'experimental-edge'. It can be updated to 'edge' instead.` expect(stripAnsi(next.cliOutput)).toInclude(
) 'The Edge Runtime is deprecated. You can use the "nodejs" runtime instead.'
)
} else {
expect(stripAnsi(next.cliOutput)).toInclude(
`/api/edge provided runtime 'experimental-edge'. It can be updated to 'edge' instead.`
)
}
}) })
it('warns about page using edge runtime', async () => { it('warns about page using experimental-edge runtime', async () => {
await next.patchFile( await next.patchFile(
pagePath, pagePath,
` `
...@@ -68,12 +75,18 @@ describe.each([ ...@@ -68,12 +75,18 @@ describe.each([
const res = await next.fetch(`/`) const res = await next.fetch(`/`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(next.cliOutput).not.toInclude('error') expect(next.cliOutput).not.toInclude('error')
expect(stripAnsi(next.cliOutput)).toInclude( if (await gate((c) => c.turbopack)) {
`You are using an experimental edge runtime, the API might change.` expect(stripAnsi(next.cliOutput)).toInclude(
) 'The Edge Runtime is deprecated. You can use the "nodejs" runtime instead.'
)
} else {
expect(stripAnsi(next.cliOutput)).toInclude(
`You are using an experimental edge runtime, the API might change.`
)
}
}) })
it('errors about page using edge runtime', async () => { it('reports diagnostics about page using edge runtime', async () => {
await next.patchFile( await next.patchFile(
pagePath, pagePath,
` `
...@@ -84,9 +97,15 @@ describe.each([ ...@@ -84,9 +97,15 @@ describe.each([
await next.start() await next.start()
const res = await next.fetch(`/`) const res = await next.fetch(`/`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(stripAnsi(next.cliOutput)).toInclude( if (await gate((c) => c.turbopack)) {
`Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.` expect(stripAnsi(next.cliOutput)).toInclude(
) 'The Edge Runtime is deprecated. You can use the "nodejs" runtime instead.'
)
} else {
expect(stripAnsi(next.cliOutput)).toInclude(
`Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`
)
}
expect(next.cliOutput).not.toInclude('warn') expect(next.cliOutput).not.toInclude('warn')
}) })
}) })
......
...@@ -8,7 +8,7 @@ import escapeStringRegexp from 'escape-string-regexp' ...@@ -8,7 +8,7 @@ import escapeStringRegexp from 'escape-string-regexp'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode. // TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// FIXME: Fails to deploy // FIXME: Fails to deploy
// @force-gate !deploy || !adapter || !turbopack // @force-gate !deploy || !adapter
describe('Middleware Rewrite', () => { describe('Middleware Rewrite', () => {
const { next, isNextDeploy } = nextTestSetup({ const { next, isNextDeploy } = nextTestSetup({
files: { files: {
......
module.exports = {
typescript: {
tsconfigPath: 'web.tsconfig.json',
},
}
export default function Index() {
return <p>Hello world</p>
}
import { nextTestSetup } from 'e2e-utils'
const warnMessage = /Using tsconfig file:/
describe('Custom TypeScript Config', () => {
// This suite controls the local build lifecycle directly, which deployment tests cannot reproduce.
// @force-gate !deploy
// @force-gate !turbopack
describe('production mode', () => {
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
})
it('should warn when using custom typescript path', async () => {
await next.build()
expect(next.cliOutput).toMatch(warnMessage)
})
})
})
{
"compilerOptions": {
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
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