Unverified Commit 2cf8e6c8 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

More Turbopack fixes (#56275)

Skips additional production-only tests.

Follow-up to https://github.com/vercel/next.js/pull/56089

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
parent e043e1f1
...@@ -2,28 +2,32 @@ import { createNext } from 'e2e-utils' ...@@ -2,28 +2,32 @@ import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils' import { renderViaHTTP } from 'next-test-utils'
describe('webpack-issuer-deprecation-warning', () => { // Skip on Turbopack because it's not supported
let next: NextInstance ;(process.env.TURBOPACK ? describe.skip : describe)(
'webpack-issuer-deprecation-warning',
() => {
let next: NextInstance
beforeAll(async () => { beforeAll(async () => {
next = await createNext({ next = await createNext({
files: { files: {
'pages/index.js': ` 'pages/index.js': `
export default function Page() { export default function Page() {
return <p>hello world return <p>hello world
} }
`, `,
}, },
dependencies: {}, dependencies: {},
})
}) })
}) afterAll(() => next.destroy())
afterAll(() => next.destroy())
it('should not appear deprecation warning about webpack module issuer', async () => { it('should not appear deprecation warning about webpack module issuer', async () => {
const html = await renderViaHTTP(next.url, '/') const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('Syntax Error') expect(html).toContain('Syntax Error')
expect(next.cliOutput).not.toContain( expect(next.cliOutput).not.toContain(
'[DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API' '[DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API'
) )
}) })
}) }
)
...@@ -7,65 +7,73 @@ import { join } from 'path' ...@@ -7,65 +7,73 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../fixtures') const fixturesDir = join(__dirname, '../fixtures')
describe('Browserslist: Old', () => { describe('Browserslist: Old', () => {
const appDir = join(fixturesDir, 'browsers-old') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'browsers-old')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => {
expect(code).toBe(0) it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/) expect(code).toBe(0)
}) expect(stdout).toMatch(/Compiled successfully/)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`"a{-webkit-animation:none 0s ease 0s 1 normal none running;animation:none 0s ease 0s 1 normal none running;-webkit-backface-visibility:visible;backface-visibility:visible;background:transparent none repeat 0 0/auto auto padding-box border-box scroll;border:none;border-collapse:separate;-webkit-border-image:none;border-image:none;-webkit-border-radius:0;border-radius:0;border-spacing:0;bottom:auto;-webkit-box-shadow:none;box-shadow:none;-webkit-box-sizing:content-box;box-sizing:content-box;caption-side:top;clear:none;clip:auto;color:#000;-webkit-columns:auto;-webkit-column-count:auto;-webkit-column-fill:balance;column-fill:balance;-webkit-column-gap:normal;column-gap:normal;-webkit-column-rule:medium none currentColor;column-rule:medium none currentColor;-webkit-column-span:1;column-span:1;-webkit-column-width:auto;columns:auto;content:normal;counter-increment:none;counter-reset:none;cursor:auto;direction:ltr;display:inline;empty-cells:show;float:none;font-family:serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;line-height:normal;height:auto;-ms-hyphens:none;hyphens:none;left:auto;letter-spacing:normal;list-style:disc none outside;margin:0;max-height:none;max-width:none;min-height:0;min-width:0;opacity:1;orphans:2;outline:medium none invert;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;-webkit-perspective:none;perspective:none;-webkit-perspective-origin:50% 50%;perspective-origin:50% 50%;position:static;right:auto;tab-size:8;table-layout:auto;text-align:left;text-align-last:auto;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;top:auto;-webkit-transform:none;transform:none;-webkit-transform-origin:50% 50% 0;transform-origin:50% 50% 0;-webkit-transform-style:flat;transform-style:flat;-webkit-transition:none 0s ease 0s;transition:none 0s ease 0s;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:2;width:auto;word-spacing:normal;z-index:auto;all:initial}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:2dppx){.image{background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}}"` expect(
) cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(
`"a{-webkit-animation:none 0s ease 0s 1 normal none running;animation:none 0s ease 0s 1 normal none running;-webkit-backface-visibility:visible;backface-visibility:visible;background:transparent none repeat 0 0/auto auto padding-box border-box scroll;border:none;border-collapse:separate;-webkit-border-image:none;border-image:none;-webkit-border-radius:0;border-radius:0;border-spacing:0;bottom:auto;-webkit-box-shadow:none;box-shadow:none;-webkit-box-sizing:content-box;box-sizing:content-box;caption-side:top;clear:none;clip:auto;color:#000;-webkit-columns:auto;-webkit-column-count:auto;-webkit-column-fill:balance;column-fill:balance;-webkit-column-gap:normal;column-gap:normal;-webkit-column-rule:medium none currentColor;column-rule:medium none currentColor;-webkit-column-span:1;column-span:1;-webkit-column-width:auto;columns:auto;content:normal;counter-increment:none;counter-reset:none;cursor:auto;direction:ltr;display:inline;empty-cells:show;float:none;font-family:serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;line-height:normal;height:auto;-ms-hyphens:none;hyphens:none;left:auto;letter-spacing:normal;list-style:disc none outside;margin:0;max-height:none;max-width:none;min-height:0;min-width:0;opacity:1;orphans:2;outline:medium none invert;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;-webkit-perspective:none;perspective:none;-webkit-perspective-origin:50% 50%;perspective-origin:50% 50%;position:static;right:auto;tab-size:8;table-layout:auto;text-align:left;text-align-last:auto;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;top:auto;-webkit-transform:none;transform:none;-webkit-transform-origin:50% 50% 0;transform-origin:50% 50% 0;-webkit-transform-style:flat;transform-style:flat;-webkit-transition:none 0s ease 0s;transition:none 0s ease 0s;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:2;width:auto;word-spacing:normal;z-index:auto;all:initial}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:2dppx){.image{background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}}"`
)
})
}) })
}) })
describe('Browserslist: New', () => { describe('Browserslist: New', () => {
const appDir = join(fixturesDir, 'browsers-new') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'browsers-new')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => {
expect(code).toBe(0) it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/) expect(code).toBe(0)
}) expect(stdout).toMatch(/Compiled successfully/)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`"a{all:initial}@media (min-resolution:2dppx){.image{background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}}"` expect(
) cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(
`"a{all:initial}@media (min-resolution:2dppx){.image{background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}}"`
)
})
}) })
}) })
...@@ -7,119 +7,129 @@ import { join } from 'path' ...@@ -7,119 +7,129 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../fixtures') const fixturesDir = join(__dirname, '../fixtures')
describe('Custom Properties: Fail for :root {} in CSS Modules', () => { describe('Custom Properties: Fail for :root {} in CSS Modules', () => {
const appDir = join(fixturesDir, 'cp-global-modules') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'cp-global-modules')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.module.css')
expect(stderr).toContain('Selector ":root" is not pure')
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.module.css')
expect(stderr).toContain('Selector ":root" is not pure')
}) })
}) })
describe('Custom Properties: Fail for global element in CSS Modules', () => { describe('Custom Properties: Fail for global element in CSS Modules', () => {
const appDir = join(fixturesDir, 'cp-el-modules') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'cp-el-modules')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.module.css')
expect(stderr).toContain('Selector "h1" is not pure')
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.module.css')
expect(stderr).toContain('Selector "h1" is not pure')
}) })
}) })
describe('CSS Modules: Import Global CSS', () => { describe('CSS Modules: Import Global CSS', () => {
const appDir = join(fixturesDir, 'module-import-global') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'module-import-global')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => { it('should have compiled successfully', () => {
expect(code).toBe(0) expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/) expect(stdout).toMatch(/Compiled successfully/)
}) })
it(`should've emitted a single CSS file`, async () => { it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1) expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot( expect(
`"a .styles_foo__G5630{all:initial}"` cssContent.replace(/\/\*.*?\*\//g, '').trim()
) ).toMatchInlineSnapshot(`"a .styles_foo__G5630{all:initial}"`)
})
}) })
}) })
describe('CSS Modules: Importing Invalid Global CSS', () => { describe('CSS Modules: Importing Invalid Global CSS', () => {
const appDir = join(fixturesDir, 'module-import-global-invalid') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'module-import-global-invalid')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.css')
expect(stderr).toContain('Selector "a" is not pure')
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('pages/styles.css')
expect(stderr).toContain('Selector "a" is not pure')
}) })
}) })
describe('CSS Modules: Import Exports', () => { describe('CSS Modules: Import Exports', () => {
const appDir = join(fixturesDir, 'module-import-exports') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'module-import-exports')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => { it('should have compiled successfully', () => {
expect(code).toBe(0) expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/) expect(stdout).toMatch(/Compiled successfully/)
}) })
it(`should've emitted a single CSS file`, async () => { it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1) expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot( expect(
`".styles_blk__480DC{color:#000}"` cssContent.replace(/\/\*.*?\*\//g, '').trim()
) ).toMatchInlineSnapshot(`".styles_blk__480DC{color:#000}"`)
})
}) })
}) })
...@@ -7,97 +7,103 @@ import { join } from 'path' ...@@ -7,97 +7,103 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../fixtures') const fixturesDir = join(__dirname, '../fixtures')
describe('Custom Properties: Pass-Through IE11', () => { describe('Custom Properties: Pass-Through IE11', () => {
const appDir = join(fixturesDir, 'cp-ie-11') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'cp-ie-11')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => {
expect(code).toBe(0) it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/) expect(code).toBe(0)
}) expect(stdout).toMatch(/Compiled successfully/)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`":root{--color:red}h1{color:var(--color)}"` expect(
) cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`":root{--color:red}h1{color:var(--color)}"`)
})
}) })
}) })
describe('Custom Properties: Pass-Through Modern', () => { describe('Custom Properties: Pass-Through Modern', () => {
const appDir = join(fixturesDir, 'cp-modern') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'cp-modern')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => {
expect(code).toBe(0) it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/) expect(code).toBe(0)
}) expect(stdout).toMatch(/Compiled successfully/)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`":root{--color:red}h1{color:var(--color)}"` expect(
) cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`":root{--color:red}h1{color:var(--color)}"`)
})
}) })
}) })
describe('Inline Comments: Minify', () => { describe('Inline Comments: Minify', () => {
const appDir = join(fixturesDir, 'inline-comments') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'inline-comments')
let stdout
let code let stdout
beforeAll(async () => { let code
await remove(join(appDir, '.next')) beforeAll(async () => {
;({ code, stdout } = await nextBuild(appDir, [], { await remove(join(appDir, '.next'))
stdout: true, ;({ code, stdout } = await nextBuild(appDir, [], {
})) stdout: true,
}) }))
})
it('should have compiled successfully', () => {
expect(code).toBe(0) it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/) expect(code).toBe(0)
}) expect(stdout).toMatch(/Compiled successfully/)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`"*{box-sizing:border-box}"` expect(
) cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`"*{box-sizing:border-box}"`)
})
}) })
}) })
...@@ -7,112 +7,122 @@ import { join } from 'path' ...@@ -7,112 +7,122 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures') const fixturesDir = join(__dirname, '../..', 'css-fixtures')
describe('Invalid CSS in _document', () => { describe('Invalid CSS in _document', () => {
const appDir = join(fixturesDir, 'invalid-module-document') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-module-document')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles.module.css')
expect(stderr).toMatch(
/CSS.*cannot.*be imported within.*pages[\\/]_document\.js/
)
expect(stderr).toMatch(/Location:.*pages[\\/]_document\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles.module.css')
expect(stderr).toMatch(
/CSS.*cannot.*be imported within.*pages[\\/]_document\.js/
)
expect(stderr).toMatch(/Location:.*pages[\\/]_document\.js/)
}) })
}) })
describe('Invalid Global CSS', () => { describe('Invalid Global CSS', () => {
const appDir = join(fixturesDir, 'invalid-global') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
}) })
describe('Valid Global CSS from npm', () => { describe('Valid Global CSS from npm', () => {
const appDir = join(fixturesDir, 'import-global-from-module') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'import-global-from-module')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should compile successfully', async () => { it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], { const { code, stdout } = await nextBuild(appDir, [], {
stdout: true, stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
}) })
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it(`should've emitted a single CSS file`, async () => { it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css') const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder) const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f)) const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1) expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8') const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot( expect(
`".red-text{color:\\"red\\"}"` cssContent.replace(/\/\*.*?\*\//g, '').trim()
) ).toMatchInlineSnapshot(`".red-text{color:\\"red\\"}"`)
})
}) })
}) })
describe('Invalid Global CSS with Custom App', () => { describe('Invalid Global CSS with Custom App', () => {
const appDir = join(fixturesDir, 'invalid-global-with-app') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global-with-app')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
}) })
describe('Valid and Invalid Global CSS with Custom App', () => { describe('Valid and Invalid Global CSS with Custom App', () => {
const appDir = join(fixturesDir, 'valid-and-invalid-global') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'valid-and-invalid-global')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toContain('Please move all first-party global CSS imports')
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toContain('Please move all first-party global CSS imports')
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
}) })
...@@ -5,17 +5,21 @@ import { nextBuild } from 'next-test-utils' ...@@ -5,17 +5,21 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
describe('Reports stack trace when webpack plugin stack overflows', () => { // This test is skipped because it's not relevant to Turbopack.
it('shows details in next build', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)(
const { code, stderr } = await nextBuild(appDir, undefined, { 'Reports stack trace when webpack plugin stack overflows',
stderr: true, () => {
ignoreFail: true, it('shows details in next build', async () => {
const { code, stderr } = await nextBuild(appDir, undefined, {
stderr: true,
ignoreFail: true,
})
expect(code).toBe(1)
expect(stderr).toContain(
'caused by plugins in Compilation.hooks.processAssets'
)
expect(stderr).toContain('Maximum call stack size exceeded')
expect(stderr).toContain('next.config.js:7')
}) })
expect(code).toBe(1) }
expect(stderr).toContain( )
'caused by plugins in Compilation.hooks.processAssets'
)
expect(stderr).toContain('Maximum call stack size exceeded')
expect(stderr).toContain('next.config.js:7')
})
})
...@@ -11,167 +11,177 @@ const nextConfig = new File(join(appDir, 'next.config.js')) ...@@ -11,167 +11,177 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
const pagesIndexJs = new File(join(appDir, 'pages', 'index.js')) const pagesIndexJs = new File(join(appDir, 'pages', 'index.js'))
describe('Export with cloudinary loader next/image component', () => { describe('Export with cloudinary loader next/image component', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await nextConfig.replace( beforeAll(async () => {
'{ /* replaceme */ }', await nextConfig.replace(
JSON.stringify({ '{ /* replaceme */ }',
images: { JSON.stringify({
loader: 'cloudinary', images: {
path: 'https://example.com/', loader: 'cloudinary',
}, path: 'https://example.com/',
}) },
) })
}) )
it('should build successfully', async () => { })
await fs.remove(join(appDir, '.next')) it('should build successfully', async () => {
const { code } = await nextBuild(appDir) await fs.remove(join(appDir, '.next'))
if (code !== 0) throw new Error(`build failed with status ${code}`) const { code } = await nextBuild(appDir)
}) if (code !== 0) throw new Error(`build failed with status ${code}`)
})
it('should export successfully', async () => {
const { code } = await nextExport(appDir, { outdir }) it('should export successfully', async () => {
if (code !== 0) throw new Error(`export failed with status ${code}`) const { code } = await nextExport(appDir, { outdir })
}) if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should contain img element in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html')) it('should contain img element in html output', async () => {
const $ = cheerio.load(html) const html = await fs.readFile(join(outdir, 'index.html'))
expect($('img[alt="icon"]').attr('alt')).toBe('icon') const $ = cheerio.load(html)
}) expect($('img[alt="icon"]').attr('alt')).toBe('icon')
})
afterAll(async () => {
await nextConfig.restore() afterAll(async () => {
await nextConfig.restore()
})
}) })
}) })
describe('Export with custom loader next/image component', () => { describe('Export with custom loader next/image component', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await nextConfig.replace( beforeAll(async () => {
'{ /* replaceme */ }', await nextConfig.replace(
JSON.stringify({ '{ /* replaceme */ }',
images: { JSON.stringify({
loader: 'custom', images: {
}, loader: 'custom',
}) },
) })
await pagesIndexJs.replace( )
'loader = undefined', await pagesIndexJs.replace(
'loader = ({src}) => "/custom" + src' 'loader = undefined',
) 'loader = ({src}) => "/custom" + src'
}) )
it('should build successfully', async () => { })
await fs.remove(join(appDir, '.next')) it('should build successfully', async () => {
const { code } = await nextBuild(appDir) await fs.remove(join(appDir, '.next'))
if (code !== 0) throw new Error(`build failed with status ${code}`) const { code } = await nextBuild(appDir)
}) if (code !== 0) throw new Error(`build failed with status ${code}`)
})
it('should export successfully', async () => {
const { code } = await nextExport(appDir, { outdir }) it('should export successfully', async () => {
if (code !== 0) throw new Error(`export failed with status ${code}`) const { code } = await nextExport(appDir, { outdir })
}) if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should contain img element with same src in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html')) it('should contain img element with same src in html output', async () => {
const $ = cheerio.load(html) const html = await fs.readFile(join(outdir, 'index.html'))
expect($('img[src="/custom/o.png"]')).toBeDefined() const $ = cheerio.load(html)
}) expect($('img[src="/custom/o.png"]')).toBeDefined()
})
afterAll(async () => {
await nextConfig.restore() afterAll(async () => {
await pagesIndexJs.restore() await nextConfig.restore()
await pagesIndexJs.restore()
})
}) })
}) })
describe('Export with custom loader config but no loader prop on next/image', () => { describe('Export with custom loader config but no loader prop on next/image', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await nextConfig.replace( beforeAll(async () => {
'{ /* replaceme */ }', await nextConfig.replace(
JSON.stringify({ '{ /* replaceme */ }',
images: { JSON.stringify({
loader: 'custom', images: {
}, loader: 'custom',
}) },
) })
}) )
it('should fail build', async () => { })
await fs.remove(join(appDir, '.next')) it('should fail build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { stderr: true }) await fs.remove(join(appDir, '.next'))
expect(code).toBe(1) const { code, stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toContain( expect(code).toBe(1)
'Error: Image with src "/i.png" is missing "loader" prop' expect(stderr).toContain(
) 'Error: Image with src "/i.png" is missing "loader" prop'
}) )
})
afterAll(async () => {
await nextConfig.restore() afterAll(async () => {
await pagesIndexJs.restore() await nextConfig.restore()
await pagesIndexJs.restore()
})
}) })
}) })
describe('Export with loaderFile config next/image component', () => { describe('Export with loaderFile config next/image component', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await nextConfig.replace( beforeAll(async () => {
'{ /* replaceme */ }', await nextConfig.replace(
JSON.stringify({ '{ /* replaceme */ }',
images: { JSON.stringify({
loader: 'custom', images: {
loaderFile: './dummy-loader.js', loader: 'custom',
}, loaderFile: './dummy-loader.js',
}) },
) })
}) )
it('should build successfully', async () => { })
await fs.remove(join(appDir, '.next')) it('should build successfully', async () => {
const { code } = await nextBuild(appDir) await fs.remove(join(appDir, '.next'))
if (code !== 0) throw new Error(`build failed with status ${code}`) const { code } = await nextBuild(appDir)
}) if (code !== 0) throw new Error(`build failed with status ${code}`)
})
it('should export successfully', async () => {
const { code } = await nextExport(appDir, { outdir }) it('should export successfully', async () => {
if (code !== 0) throw new Error(`export failed with status ${code}`) const { code } = await nextExport(appDir, { outdir })
}) if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should contain img element with same src in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html')) it('should contain img element with same src in html output', async () => {
const $ = cheerio.load(html) const html = await fs.readFile(join(outdir, 'index.html'))
expect($('img[src="/i.png#w:32,q:50"]')).toBeDefined() const $ = cheerio.load(html)
}) expect($('img[src="/i.png#w:32,q:50"]')).toBeDefined()
})
afterAll(async () => {
await nextConfig.restore() afterAll(async () => {
await pagesIndexJs.restore() await nextConfig.restore()
await pagesIndexJs.restore()
})
}) })
}) })
describe('Export with unoptimized next/image component', () => { describe('Export with unoptimized next/image component', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await nextConfig.replace( beforeAll(async () => {
'{ /* replaceme */ }', await nextConfig.replace(
JSON.stringify({ '{ /* replaceme */ }',
images: { JSON.stringify({
unoptimized: true, images: {
}, unoptimized: true,
}) },
) })
}) )
it('should build successfully', async () => { })
await fs.remove(join(appDir, '.next')) it('should build successfully', async () => {
const { code } = await nextBuild(appDir) await fs.remove(join(appDir, '.next'))
if (code !== 0) throw new Error(`build failed with status ${code}`) const { code } = await nextBuild(appDir)
}) if (code !== 0) throw new Error(`build failed with status ${code}`)
})
it('should export successfully', async () => {
const { code } = await nextExport(appDir, { outdir }) it('should export successfully', async () => {
if (code !== 0) throw new Error(`export failed with status ${code}`) const { code } = await nextExport(appDir, { outdir })
}) if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should contain img element with same src in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html')) it('should contain img element with same src in html output', async () => {
const $ = cheerio.load(html) const html = await fs.readFile(join(outdir, 'index.html'))
expect($('img[src="/o.png"]')).toBeDefined() const $ = cheerio.load(html)
}) expect($('img[src="/o.png"]')).toBeDefined()
})
afterAll(async () => {
await nextConfig.restore() afterAll(async () => {
await nextConfig.restore()
})
}) })
}) })
...@@ -15,29 +15,31 @@ let appPort ...@@ -15,29 +15,31 @@ let appPort
let app let app
describe("Handle ESM externals with esmExternals: 'loose'", () => { describe("Handle ESM externals with esmExternals: 'loose'", () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await fs.remove(join(appDir, '.next')) beforeAll(async () => {
await nextBuild(appDir) await fs.remove(join(appDir, '.next'))
appPort = await findPort() await nextBuild(appDir)
app = await nextStart(appDir, appPort) appPort = await findPort()
}) app = await nextStart(appDir, appPort)
afterAll(() => killApp(app)) })
afterAll(() => killApp(app))
const expected = const expected =
/Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World/ /Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World/
it('should render the static page', async () => { it('should render the static page', async () => {
const html = await renderViaHTTP(appPort, '/static') const html = await renderViaHTTP(appPort, '/static')
expect(html).toMatch(expected) expect(html).toMatch(expected)
}) })
it('should render the ssr page', async () => { it('should render the ssr page', async () => {
const html = await renderViaHTTP(appPort, '/ssr') const html = await renderViaHTTP(appPort, '/ssr')
expect(html).toMatch(expected) expect(html).toMatch(expected)
}) })
it('should render the ssg page', async () => { it('should render the ssg page', async () => {
const html = await renderViaHTTP(appPort, '/ssg') const html = await renderViaHTTP(appPort, '/ssg')
expect(html).toMatch(expected) expect(html).toMatch(expected)
})
}) })
}) })
...@@ -15,29 +15,31 @@ let appPort ...@@ -15,29 +15,31 @@ let appPort
let app let app
describe('Handle ESM externals with esmExternals: true', () => { describe('Handle ESM externals with esmExternals: true', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await fs.remove(join(appDir, '.next')) beforeAll(async () => {
await nextBuild(appDir) await fs.remove(join(appDir, '.next'))
appPort = await findPort() await nextBuild(appDir)
app = await nextStart(appDir, appPort) appPort = await findPort()
}) app = await nextStart(appDir, appPort)
afterAll(() => killApp(app)) })
afterAll(() => killApp(app))
const expected = const expected =
/Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World\+World\+World/ /Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World\+World\+World/
it('should render the static page', async () => { it('should render the static page', async () => {
const html = await renderViaHTTP(appPort, '/static') const html = await renderViaHTTP(appPort, '/static')
expect(html).toMatch(expected) expect(html).toMatch(expected)
}) })
it('should render the ssr page', async () => { it('should render the ssr page', async () => {
const html = await renderViaHTTP(appPort, '/ssr') const html = await renderViaHTTP(appPort, '/ssr')
expect(html).toMatch(expected) expect(html).toMatch(expected)
}) })
it('should render the ssg page', async () => { it('should render the ssg page', async () => {
const html = await renderViaHTTP(appPort, '/ssg') const html = await renderViaHTTP(appPort, '/ssg')
expect(html).toMatch(expected) expect(html).toMatch(expected)
})
}) })
}) })
...@@ -13,10 +13,11 @@ const writePage = async (content, testPage = join(pagesDir, 'test.js')) => { ...@@ -13,10 +13,11 @@ const writePage = async (content, testPage = join(pagesDir, 'test.js')) => {
} }
describe('GSP build errors', () => { describe('GSP build errors', () => {
afterEach(() => fs.remove(pagesDir)) ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(() => fs.remove(pagesDir))
it('should fail build from module not found', async () => { it('should fail build from module not found', async () => {
await writePage(` await writePage(`
__non_webpack_require__('a-cool-module') __non_webpack_require__('a-cool-module')
export function getStaticProps() { export function getStaticProps() {
...@@ -29,13 +30,13 @@ describe('GSP build errors', () => { ...@@ -29,13 +30,13 @@ describe('GSP build errors', () => {
return null return null
} }
`) `)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('a-cool-module') expect(stderr).toContain('a-cool-module')
}) })
it('should fail build from ENOENT in getStaticProps', async () => { it('should fail build from ENOENT in getStaticProps', async () => {
await writePage(` await writePage(`
export function getStaticProps() { export function getStaticProps() {
require('fs').readFileSync('a-cool-file') require('fs').readFileSync('a-cool-file')
...@@ -48,13 +49,13 @@ describe('GSP build errors', () => { ...@@ -48,13 +49,13 @@ describe('GSP build errors', () => {
return null return null
} }
`) `)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('a-cool-file') expect(stderr).toContain('a-cool-file')
}) })
it('should fail build on normal error in getStaticProps', async () => { it('should fail build on normal error in getStaticProps', async () => {
await writePage(` await writePage(`
export function getStaticProps() { export function getStaticProps() {
throw new Error('a cool error') throw new Error('a cool error')
return { return {
...@@ -66,13 +67,13 @@ describe('GSP build errors', () => { ...@@ -66,13 +67,13 @@ describe('GSP build errors', () => {
return null return null
} }
`) `)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('a cool error') expect(stderr).toContain('a cool error')
}) })
it('should fail build from undefined error in getStaticProps', async () => { it('should fail build from undefined error in getStaticProps', async () => {
await writePage(` await writePage(`
export function getStaticProps() { export function getStaticProps() {
throw undefined throw undefined
return { return {
...@@ -84,13 +85,13 @@ describe('GSP build errors', () => { ...@@ -84,13 +85,13 @@ describe('GSP build errors', () => {
return null return null
} }
`) `)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('undefined') expect(stderr).toContain('undefined')
}) })
it('should fail build from string error in getStaticProps', async () => { it('should fail build from string error in getStaticProps', async () => {
await writePage(` await writePage(`
export function getStaticProps() { export function getStaticProps() {
throw 'a string error' throw 'a string error'
return { return {
...@@ -102,13 +103,13 @@ describe('GSP build errors', () => { ...@@ -102,13 +103,13 @@ describe('GSP build errors', () => {
return null return null
} }
`) `)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('a string error') expect(stderr).toContain('a string error')
}) })
it('should handle non-serializable error in getStaticProps', async () => { it('should handle non-serializable error in getStaticProps', async () => {
await writePage(` await writePage(`
export function getStaticProps() { export function getStaticProps() {
const err = new Error('my custom error') const err = new Error('my custom error')
err.hello = 'world' err.hello = 'world'
...@@ -127,14 +128,14 @@ describe('GSP build errors', () => { ...@@ -127,14 +128,14 @@ describe('GSP build errors', () => {
return null return null
} }
`) `)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('my custom error') expect(stderr).toContain('my custom error')
}) })
it('should handle non-serializable error in getStaticPaths', async () => { it('should handle non-serializable error in getStaticPaths', async () => {
await writePage( await writePage(
` `
export function getStaticProps() { export function getStaticProps() {
return { return {
props: {} props: {}
...@@ -160,10 +161,11 @@ describe('GSP build errors', () => { ...@@ -160,10 +161,11 @@ describe('GSP build errors', () => {
return null return null
} }
`, `,
join(pagesDir, '[slug].js') join(pagesDir, '[slug].js')
) )
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1) expect(code).toBe(1)
expect(stderr).toContain('my custom error') expect(stderr).toContain('my custom error')
})
}) })
}) })
...@@ -107,7 +107,7 @@ const runTests = () => { ...@@ -107,7 +107,7 @@ const runTests = () => {
}) })
} }
describe('Custom routes i18n', () => { describe('Custom routes i18n custom error', () => {
describe('dev mode', () => { describe('dev mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
......
...@@ -75,7 +75,7 @@ const runTests = () => { ...@@ -75,7 +75,7 @@ const runTests = () => {
}) })
} }
describe('Custom routes i18n', () => { describe('Custom routes i18n support index rewrite', () => {
describe('dev mode', () => { describe('dev mode', () => {
beforeAll(async () => { beforeAll(async () => {
appPort = await findPort() appPort = await findPort()
......
...@@ -89,20 +89,22 @@ const runTests = (isDev = false) => { ...@@ -89,20 +89,22 @@ const runTests = (isDev = false) => {
} }
describe('Build Error Tests for basePath', () => { describe('Build Error Tests for basePath', () => {
it('should throw build error when import statement is used with missing file', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await indexPage.replace( it('should throw build error when import statement is used with missing file', async () => {
'../public/foo/test-rect.jpg', await indexPage.replace(
'../public/foo/test-rect-broken.jpg' '../public/foo/test-rect.jpg',
) '../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore() await indexPage.restore()
expect(stderr).toContain( expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg" "Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
) )
// should contain the importing module // should contain the importing module
expect(stderr).toContain('./pages/static-img.js') expect(stderr).toContain('./pages/static-img.js')
})
}) })
}) })
describe('Static Image Component Tests for basePath', () => { describe('Static Image Component Tests for basePath', () => {
......
...@@ -99,34 +99,38 @@ const runTests = () => { ...@@ -99,34 +99,38 @@ const runTests = () => {
} }
describe('Build Error Tests', () => { describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await indexPage.replace( it('should throw build error when import statement is used with missing file', async () => {
'../public/foo/test-rect.jpg', await indexPage.replace(
'../public/foo/test-rect-broken.jpg' '../public/foo/test-rect.jpg',
) '../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore() await indexPage.restore()
expect(stderr).toContain( expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg" "Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
) )
// should contain the importing module // should contain the importing module
expect(stderr).toContain('./pages/static-img.js') expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace // should contain a import trace
expect(stderr).not.toContain('Import trace for requested module') expect(stderr).not.toContain('Import trace for requested module')
})
}) })
}) })
describe('Static Image Component Tests', () => { describe('Static Image Component Tests', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await nextBuild(appDir) beforeAll(async () => {
appPort = await findPort() await nextBuild(appDir)
app = await nextStart(appDir, appPort) appPort = await findPort()
html = await renderViaHTTP(appPort, '/static-img') app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/static-img') html = await renderViaHTTP(appPort, '/static-img')
}) browser = await webdriver(appPort, '/static-img')
afterAll(() => { })
killApp(app) afterAll(() => {
killApp(app)
})
runTests()
}) })
runTests()
}) })
...@@ -186,22 +186,24 @@ const runTests = (isDev) => { ...@@ -186,22 +186,24 @@ const runTests = (isDev) => {
} }
describe('Build Error Tests', () => { describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await indexPage.replace( it('should throw build error when import statement is used with missing file', async () => {
'../../public/foo/test-rect.jpg', await indexPage.replace(
'../../public/foo/test-rect-broken.jpg' '../../public/foo/test-rect.jpg',
) '../../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore() await indexPage.restore()
expect(stderr).toContain( expect(stderr).toContain(
"Module not found: Can't resolve '../../public/foo/test-rect-broken.jpg" "Module not found: Can't resolve '../../public/foo/test-rect-broken.jpg"
) )
// should contain the importing module // should contain the importing module
expect(stderr).toContain('./app/static-img/page.js') expect(stderr).toContain('./app/static-img/page.js')
// should contain a import trace // should contain a import trace
expect(stderr).not.toContain('Import trace for requested module') expect(stderr).not.toContain('Import trace for requested module')
})
}) })
}) })
describe('Static Image Component Tests', () => { describe('Static Image Component Tests', () => {
......
...@@ -144,22 +144,24 @@ const runTests = (isDev) => { ...@@ -144,22 +144,24 @@ const runTests = (isDev) => {
} }
describe('Build Error Tests', () => { describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await indexPage.replace( it('should throw build error when import statement is used with missing file', async () => {
'../public/foo/test-rect.jpg', await indexPage.replace(
'../public/foo/test-rect-broken.jpg' '../public/foo/test-rect.jpg',
) '../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore() await indexPage.restore()
expect(stderr).toContain( expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg" "Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
) )
// should contain the importing module // should contain the importing module
expect(stderr).toContain('./pages/static-img.js') expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace // should contain a import trace
expect(stderr).not.toContain('Import trace for requested module') expect(stderr).not.toContain('Import trace for requested module')
})
}) })
}) })
describe('Static Image Component Tests for basePath', () => { describe('Static Image Component Tests for basePath', () => {
......
...@@ -198,22 +198,24 @@ const runTests = (isDev) => { ...@@ -198,22 +198,24 @@ const runTests = (isDev) => {
} }
describe('Build Error Tests', () => { describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await indexPage.replace( it('should throw build error when import statement is used with missing file', async () => {
'../public/foo/test-rect.jpg', await indexPage.replace(
'../public/foo/test-rect-broken.jpg' '../public/foo/test-rect.jpg',
) '../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore() await indexPage.restore()
expect(stderr).toContain( expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg" "Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
) )
// should contain the importing module // should contain the importing module
expect(stderr).toContain('./pages/static-img.js') expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace // should contain a import trace
expect(stderr).not.toContain('Import trace for requested module') expect(stderr).not.toContain('Import trace for requested module')
})
}) })
}) })
describe('Static Image Component Tests', () => { describe('Static Image Component Tests', () => {
......
...@@ -15,18 +15,19 @@ const addPage = async (page, content) => { ...@@ -15,18 +15,19 @@ const addPage = async (page, content) => {
} }
describe('no-op export', () => { describe('no-op export', () => {
afterEach(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await Promise.all( afterEach(async () => {
['.next', 'pages', 'next.config.js', 'out'].map((file) => await Promise.all(
fs.remove(join(appDir, file)) ['.next', 'pages', 'next.config.js', 'out'].map((file) =>
fs.remove(join(appDir, file))
)
) )
) })
})
it('should not error for all server-side pages build', async () => { it('should not error for all server-side pages build', async () => {
await addPage( await addPage(
'_error.js', '_error.js',
` `
import React from 'react' import React from 'react'
export default class Error extends React.Component { export default class Error extends React.Component {
static async getInitialProps() { static async getInitialProps() {
...@@ -41,10 +42,10 @@ describe('no-op export', () => { ...@@ -41,10 +42,10 @@ describe('no-op export', () => {
} }
} }
` `
) )
await addPage( await addPage(
'[slug].js', '[slug].js',
` `
export const getStaticProps = () => { export const getStaticProps = () => {
return { return {
props: {} props: {}
...@@ -60,42 +61,43 @@ describe('no-op export', () => { ...@@ -60,42 +61,43 @@ describe('no-op export', () => {
return 'page' return 'page'
} }
` `
) )
const result = await nextBuild(appDir, undefined, { const result = await nextBuild(appDir, undefined, {
stderr: 'log', stderr: 'log',
stdout: 'log', stdout: 'log',
})
expect(result.code).toBe(0)
}) })
expect(result.code).toBe(0)
})
it('should not error for empty exportPathMap', async () => { it('should not error for empty exportPathMap', async () => {
await addPage( await addPage(
'index.js', 'index.js',
` `
export default function Index() { export default function Index() {
return 'hello world' return 'hello world'
} }
` `
) )
await fs.writeFile( await fs.writeFile(
nextConfig, nextConfig,
` `
module.exports = { module.exports = {
exportPathMap() { exportPathMap() {
return {} return {}
} }
} }
` `
) )
const buildResult = await nextBuild(appDir, undefined, { const buildResult = await nextBuild(appDir, undefined, {
stderr: 'log', stderr: 'log',
stdout: 'log', stdout: 'log',
}) })
expect(buildResult.code).toBe(0) expect(buildResult.code).toBe(0)
const exportResult = await nextExport(appDir, { const exportResult = await nextExport(appDir, {
outdir: join(appDir, 'out'), outdir: join(appDir, 'out'),
})
expect(exportResult.code).toBe(0)
}) })
expect(exportResult.code).toBe(0)
}) })
}) })
...@@ -28,7 +28,8 @@ const startServer = async (optEnv = {}, opts) => { ...@@ -28,7 +28,8 @@ const startServer = async (optEnv = {}, opts) => {
context.server = await initNextServerScript(scriptPath, /ready on/i, env) context.server = await initNextServerScript(scriptPath, /ready on/i, env)
} }
describe('On Demand Entries', () => { // Tests are skipped in Turbopack because they are not relevant to Turbopack.
;(process.env.TURBOPACK ? describe.skip : describe)('On Demand Entries', () => {
it('should pass', () => {}) it('should pass', () => {})
beforeAll(async () => { beforeAll(async () => {
await startServer() await startServer()
......
...@@ -7,15 +7,17 @@ import { join } from 'path' ...@@ -7,15 +7,17 @@ import { join } from 'path'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('Polyfilling (minimal)', () => { describe('Polyfilling (minimal)', () => {
beforeAll(async () => { ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
await remove(join(appDir, '.next')) beforeAll(async () => {
}) await remove(join(appDir, '.next'))
})
it('should compile successfully', async () => { it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], { const { code, stdout } = await nextBuild(appDir, [], {
stdout: true, stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
}) })
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
}) })
}) })
...@@ -10,45 +10,47 @@ let appPort ...@@ -10,45 +10,47 @@ let appPort
let app let app
describe('Polyfills', () => { describe('Polyfills', () => {
let output = '' ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let output = ''
beforeAll(async () => {
const { stdout, stderr } = await nextBuild(appDir, [], { beforeAll(async () => {
stdout: true, const { stdout, stderr } = await nextBuild(appDir, [], {
stderr: true, stdout: true,
stderr: true,
})
output = (stderr || '') + (stdout + '')
console.log(stdout)
console.error(stderr)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
}) })
output = (stderr || '') + (stdout + '')
console.log(stdout)
console.error(stderr)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
it('should alias fetch', async () => { it('should alias fetch', async () => {
const browser = await webdriver(appPort, '/fetch') const browser = await webdriver(appPort, '/fetch')
const text = await browser.elementByCss('#test-status').text() const text = await browser.elementByCss('#test-status').text()
expect(text).toBe('pass') expect(text).toBe('pass')
await browser.close() await browser.close()
}) })
it('should allow using process.env when there is an element with `id` of `process`', async () => { it('should allow using process.env when there is an element with `id` of `process`', async () => {
const browser = await webdriver(appPort, '/process') const browser = await webdriver(appPort, '/process')
const text = await browser.elementByCss('#process').text() const text = await browser.elementByCss('#process').text()
expect(text).toBe('Hello, stranger') expect(text).toBe('Hello, stranger')
await browser.close() await browser.close()
}) })
it('should contain generated page count in output', async () => { it('should contain generated page count in output', async () => {
expect(output).toContain('Generating static pages (0/5)') expect(output).toContain('Generating static pages (0/5)')
expect(output).toContain('Generating static pages (5/5)') expect(output).toContain('Generating static pages (5/5)')
// we should only have 1 segment and the initial message logged out // we should only have 1 segment and the initial message logged out
expect(output.match(/Generating static pages/g).length).toBe(5) expect(output.match(/Generating static pages/g).length).toBe(5)
})
}) })
}) })
...@@ -7,84 +7,92 @@ import { join } from 'path' ...@@ -7,84 +7,92 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'scss-fixtures') const fixturesDir = join(__dirname, '../..', 'scss-fixtures')
describe('Invalid CSS in _document', () => { describe('Invalid SCSS in _document', () => {
const appDir = join(fixturesDir, 'invalid-module-document') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-module-document')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles.module.scss')
expect(stderr).toMatch(
/CSS.*cannot.*be imported within.*pages[\\/]_document\.js/
)
expect(stderr).toMatch(/Location:.*pages[\\/]_document\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles.module.scss')
expect(stderr).toMatch(
/CSS.*cannot.*be imported within.*pages[\\/]_document\.js/
)
expect(stderr).toMatch(/Location:.*pages[\\/]_document\.js/)
}) })
}) })
describe('Invalid Global CSS', () => { describe('Invalid Global CSS', () => {
const appDir = join(fixturesDir, 'invalid-global') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.scss')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.scss')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
}) })
describe('Invalid Global CSS with Custom App', () => { describe('Invalid Global CSS with Custom App', () => {
const appDir = join(fixturesDir, 'invalid-global-with-app') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global-with-app')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.scss')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.scss')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
}) })
describe('Valid and Invalid Global CSS with Custom App', () => { describe('Valid and Invalid Global CSS with Custom App', () => {
const appDir = join(fixturesDir, 'valid-and-invalid-global') ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'valid-and-invalid-global')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.scss')
expect(stderr).toContain('Please move all first-party global CSS imports')
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.scss')
expect(stderr).toContain('Please move all first-party global CSS imports')
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}) })
}) })
...@@ -65,7 +65,9 @@ describe('turbopack unsupported features log', () => { ...@@ -65,7 +65,9 @@ describe('turbopack unsupported features log', () => {
await fs.writeFile( await fs.writeFile(
nextConfigPath, nextConfigPath,
`module.exports = { `module.exports = {
assetPrefix: '/idk' experimental: {
urlImports: true
}
}` }`
) )
const appPort = await findPort() const appPort = await findPort()
...@@ -91,6 +93,6 @@ describe('turbopack unsupported features log', () => { ...@@ -91,6 +93,6 @@ describe('turbopack unsupported features log', () => {
} }
}) })
} else { } else {
it.skip('turobpack only', () => {}) it.skip('turbopack only', () => {})
} }
}) })
...@@ -3,10 +3,14 @@ import { nextBuild } from 'next-test-utils' ...@@ -3,10 +3,14 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
describe('webpack config with extensionAlias setting', () => { // Skip webpack specific test in Turbopack
it('should run correctly with an tsx file import with .js extension', async () => { ;(process.env.TURBOPACK ? describe.skip : describe)(
const { code } = await nextBuild(appDir, [], {}) 'webpack config with extensionAlias setting',
() => {
it('should run correctly with an tsx file import with .js extension', async () => {
const { code } = await nextBuild(appDir, [], {})
expect(code).toBe(0) expect(code).toBe(0)
}) })
}) }
)
...@@ -996,7 +996,9 @@ export function runProdSuite( ...@@ -996,7 +996,9 @@ export function runProdSuite(
env?: NodeJS.ProcessEnv env?: NodeJS.ProcessEnv
} }
) { ) {
return runSuite(suiteName, { appDir, env: 'prod' }, options) ;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runSuite(suiteName, { appDir, env: 'prod' }, options)
})
} }
/** /**
......
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