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'
// TODO(deploy-test-completion): Assertions may differ from a local Next.js
// server when deployed.
// @force-gate !deploy
// @force-gate !start || !turbopackDev
describe('API routes', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should return data when catch-all', async () => {
const data = await next
.fetch('/api/users/1', {})
.then((res) => res.ok && res.json())
expect(data).toEqual({ slug: ['1'] })
const res = await next.fetch('/api/users/1')
expect(res.status).toBe(200)
expect(await res.json()).toEqual({
route: 'users',
query: { slug: ['1'] },
})
})
it('should return redirect when catch-all with index and trailing slash', async () => {
......@@ -26,18 +26,14 @@ describe('API routes', () => {
})
it('should return data when catch-all with index and trailing slash', async () => {
const data = await next
.fetch('/api/users/', {})
.then((res) => res.ok && res.json())
expect(data).toEqual({})
const res = await next.fetch('/api/users/')
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ route: 'users', query: {} })
})
it('should return data when catch-all with index and no trailing slash', async () => {
const data = await next
.fetch('/api/users', {})
.then((res) => res.ok && res.json())
expect(data).toEqual({})
const res = await next.fetch('/api/users')
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ route: 'users', query: {} })
})
})
export default function (req, res) {
res.json(req.query)
res.json({ route: 'users', query: req.query })
}
import { isNextDev, nextTestSetup } from 'e2e-utils'
import { gate } from 'next-test-utils'
import { join } from 'path'
import stripAnsi from 'strip-ansi'
......@@ -6,7 +7,7 @@ const pagePath = 'pages/index.jsx'
const apiPath = 'pages/api/edge.js'
// Deploy mode exclusion: This suite mutates fixture files and asserts local build and CLI output.
// @force-gate !turbopack && !deploy
// @force-gate !deploy
describe.each([
{ appDir: join(__dirname, './app/src'), title: 'src/pages and API routes' },
{ appDir: join(__dirname, './app'), title: 'pages and API routes' },
......@@ -52,11 +53,17 @@ describe.each([
const res = await next.fetch(`/api/edge`)
expect(res.status).toEqual(200)
expect(next.cliOutput).not.toInclude('error')
expect(stripAnsi(next.cliOutput)).toInclude(
`/api/edge provided runtime 'experimental-edge'. It can be updated to 'edge' instead.`
)
if (await gate((c) => c.turbopack)) {
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(
pagePath,
`
......@@ -68,12 +75,18 @@ describe.each([
const res = await next.fetch(`/`)
expect(res.status).toEqual(200)
expect(next.cliOutput).not.toInclude('error')
expect(stripAnsi(next.cliOutput)).toInclude(
`You are using an experimental edge runtime, the API might change.`
)
if (await gate((c) => c.turbopack)) {
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(
pagePath,
`
......@@ -84,9 +97,15 @@ describe.each([
await next.start()
const res = await next.fetch(`/`)
expect(res.status).toEqual(200)
expect(stripAnsi(next.cliOutput)).toInclude(
`Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`
)
if (await gate((c) => c.turbopack)) {
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')
})
})
......
......@@ -8,7 +8,7 @@ import escapeStringRegexp from 'escape-string-regexp'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// FIXME: Fails to deploy
// @force-gate !deploy || !adapter || !turbopack
// @force-gate !deploy || !adapter
describe('Middleware Rewrite', () => {
const { next, isNextDeploy } = nextTestSetup({
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