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 #

-->
This commit is contained in:
Tim Neutkens 2023-10-02 09:42:32 +02:00 committed by GitHub
parent e043e1f1c6
commit 2cf8e6c863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 980 additions and 855 deletions

View file

@ -2,28 +2,32 @@ import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'
describe('webpack-issuer-deprecation-warning', () => {
let next: NextInstance
// Skip on Turbopack because it's not supported
;(process.env.TURBOPACK ? describe.skip : describe)(
'webpack-issuer-deprecation-warning',
() => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world
}
`,
},
dependencies: {},
},
dependencies: {},
})
})
})
afterAll(() => next.destroy())
afterAll(() => next.destroy())
it('should not appear deprecation warning about webpack module issuer', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('Syntax Error')
expect(next.cliOutput).not.toContain(
'[DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API'
)
})
})
it('should not appear deprecation warning about webpack module issuer', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('Syntax Error')
expect(next.cliOutput).not.toContain(
'[DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API'
)
})
}
)

View file

@ -7,65 +7,73 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../fixtures')
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
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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', () => {
const appDir = join(fixturesDir, 'browsers-new')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'browsers-new')
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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==)}}"`
)
})
})
})

View file

@ -7,119 +7,129 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../fixtures')
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
const appDir = join(fixturesDir, 'cp-el-modules')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'cp-el-modules')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
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
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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 .styles_foo__G5630{all:initial}"`
)
expect(
cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`"a .styles_foo__G5630{all:initial}"`)
})
})
})
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
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
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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(
`".styles_blk__480DC{color:#000}"`
)
expect(
cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`".styles_blk__480DC{color:#000}"`)
})
})
})

View file

@ -7,97 +7,103 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../fixtures')
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
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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', () => {
const appDir = join(fixturesDir, 'cp-modern')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'cp-modern')
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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', () => {
const appDir = join(fixturesDir, 'inline-comments')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'inline-comments')
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
let stdout
let code
beforeAll(async () => {
await remove(join(appDir, '.next'))
;({ code, stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})
it('should have compiled successfully', () => {
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should have 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}"`)
})
})
})

View file

@ -7,112 +7,122 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures')
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
const appDir = join(fixturesDir, 'invalid-global')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
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 () => {
await remove(join(appDir, '.next'))
})
it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
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 compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`".red-text{color:\\"red\\"}"`
)
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(
cssContent.replace(/\/\*.*?\*\//g, '').trim()
).toMatchInlineSnapshot(`".red-text{color:\\"red\\"}"`)
})
})
})
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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/)
})
})

View file

@ -5,17 +5,21 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '..')
describe('Reports stack trace when webpack plugin stack overflows', () => {
it('shows details in next build', async () => {
const { code, stderr } = await nextBuild(appDir, undefined, {
stderr: true,
ignoreFail: true,
// This test is skipped because it's not relevant to Turbopack.
;(process.env.TURBOPACK ? describe.skip : describe)(
'Reports stack trace when webpack plugin stack overflows',
() => {
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')
})
})
}
)

View file

@ -11,167 +11,177 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
const pagesIndexJs = new File(join(appDir, 'pages', 'index.js'))
describe('Export with cloudinary loader next/image component', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'cloudinary',
path: 'https://example.com/',
},
})
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
if (code !== 0) throw new Error(`build failed with status ${code}`)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'cloudinary',
path: 'https://example.com/',
},
})
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
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 })
if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should export successfully', async () => {
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'))
const $ = cheerio.load(html)
expect($('img[alt="icon"]').attr('alt')).toBe('icon')
})
it('should contain img element in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html'))
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', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
},
})
)
await pagesIndexJs.replace(
'loader = undefined',
'loader = ({src}) => "/custom" + src'
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
if (code !== 0) throw new Error(`build failed with status ${code}`)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
},
})
)
await pagesIndexJs.replace(
'loader = undefined',
'loader = ({src}) => "/custom" + src'
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
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 })
if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should export successfully', async () => {
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'))
const $ = cheerio.load(html)
expect($('img[src="/custom/o.png"]')).toBeDefined()
})
it('should contain img element with same src in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html'))
const $ = cheerio.load(html)
expect($('img[src="/custom/o.png"]')).toBeDefined()
})
afterAll(async () => {
await nextConfig.restore()
await pagesIndexJs.restore()
afterAll(async () => {
await nextConfig.restore()
await pagesIndexJs.restore()
})
})
})
describe('Export with custom loader config but no loader prop on next/image', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
},
})
)
})
it('should fail build', async () => {
await fs.remove(join(appDir, '.next'))
const { code, stderr } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain(
'Error: Image with src "/i.png" is missing "loader" prop'
)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
},
})
)
})
it('should fail build', async () => {
await fs.remove(join(appDir, '.next'))
const { code, stderr } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain(
'Error: Image with src "/i.png" is missing "loader" prop'
)
})
afterAll(async () => {
await nextConfig.restore()
await pagesIndexJs.restore()
afterAll(async () => {
await nextConfig.restore()
await pagesIndexJs.restore()
})
})
})
describe('Export with loaderFile config next/image component', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
loaderFile: './dummy-loader.js',
},
})
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
if (code !== 0) throw new Error(`build failed with status ${code}`)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
loaderFile: './dummy-loader.js',
},
})
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
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 })
if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should export successfully', async () => {
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'))
const $ = cheerio.load(html)
expect($('img[src="/i.png#w:32,q:50"]')).toBeDefined()
})
it('should contain img element with same src in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html'))
const $ = cheerio.load(html)
expect($('img[src="/i.png#w:32,q:50"]')).toBeDefined()
})
afterAll(async () => {
await nextConfig.restore()
await pagesIndexJs.restore()
afterAll(async () => {
await nextConfig.restore()
await pagesIndexJs.restore()
})
})
})
describe('Export with unoptimized next/image component', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
unoptimized: true,
},
})
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
const { code } = await nextBuild(appDir)
if (code !== 0) throw new Error(`build failed with status ${code}`)
})
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
unoptimized: true,
},
})
)
})
it('should build successfully', async () => {
await fs.remove(join(appDir, '.next'))
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 })
if (code !== 0) throw new Error(`export failed with status ${code}`)
})
it('should export successfully', async () => {
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'))
const $ = cheerio.load(html)
expect($('img[src="/o.png"]')).toBeDefined()
})
it('should contain img element with same src in html output', async () => {
const html = await fs.readFile(join(outdir, 'index.html'))
const $ = cheerio.load(html)
expect($('img[src="/o.png"]')).toBeDefined()
})
afterAll(async () => {
await nextConfig.restore()
afterAll(async () => {
await nextConfig.restore()
})
})
})

View file

@ -8,23 +8,26 @@ import fs from 'fs'
const fixturesDir = join(__dirname, '..', 'fixtures')
describe('Application Export Intent Output', () => {
describe('Default Export', () => {
const appDir = join(fixturesDir, 'default-export')
const distDir = join(appDir, '.next')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
describe('Default Export', () => {
const appDir = join(fixturesDir, 'default-export')
const distDir = join(appDir, '.next')
beforeAll(async () => {
await remove(distDir)
})
beforeAll(async () => {
await remove(distDir)
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExportDefault(appDir)
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExportDefault(appDir)
})
it('should have the expected outputs for export', () => {
expect(
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8'))
).toMatchInlineSnapshot(`
it('should have the expected outputs for export', () => {
expect(
JSON.parse(
fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')
)
).toMatchInlineSnapshot(`
Object {
"exportTrailingSlash": false,
"hasExportPathMap": false,
@ -33,39 +36,45 @@ describe('Application Export Intent Output', () => {
}
`)
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
Object {
"outDirectory": "out",
"success": true,
"version": 1,
}
`)
})
})
})
describe('Custom Export', () => {
const appDir = join(fixturesDir, 'custom-export')
const distDir = join(appDir, '.next')
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
const appDir = join(fixturesDir, 'custom-export')
const distDir = join(appDir, '.next')
beforeAll(async () => {
await remove(distDir)
})
beforeAll(async () => {
await remove(distDir)
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExportDefault(appDir)
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExportDefault(appDir)
})
it('should have the expected outputs for export', () => {
expect(
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8'))
).toMatchInlineSnapshot(`
it('should have the expected outputs for export', () => {
expect(
JSON.parse(
fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')
)
).toMatchInlineSnapshot(`
Object {
"exportTrailingSlash": false,
"hasExportPathMap": true,
@ -74,39 +83,46 @@ describe('Application Export Intent Output', () => {
}
`)
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
Object {
"outDirectory": "out",
"success": true,
"version": 1,
}
`)
})
})
}
)
})
describe('Custom Out', () => {
const appDir = join(fixturesDir, 'custom-out')
const distDir = join(appDir, '.next')
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
const appDir = join(fixturesDir, 'custom-out')
const distDir = join(appDir, '.next')
beforeAll(async () => {
await remove(distDir)
})
beforeAll(async () => {
await remove(distDir)
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir: join(appDir, 'lel') })
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir: join(appDir, 'lel') })
})
it('should have the expected outputs for export', () => {
expect(
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8'))
).toMatchInlineSnapshot(`
it('should have the expected outputs for export', () => {
expect(
JSON.parse(
fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')
)
).toMatchInlineSnapshot(`
Object {
"exportTrailingSlash": true,
"hasExportPathMap": false,
@ -115,39 +131,46 @@ describe('Application Export Intent Output', () => {
}
`)
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
Object {
"outDirectory": "lel",
"success": true,
"version": 1,
}
`)
})
})
}
)
})
describe('Bad Export', () => {
const appDir = join(fixturesDir, 'bad-export')
const distDir = join(appDir, '.next')
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
const appDir = join(fixturesDir, 'bad-export')
const distDir = join(appDir, '.next')
beforeAll(async () => {
await remove(distDir)
})
beforeAll(async () => {
await remove(distDir)
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExportDefault(appDir, { ignoreFail: true })
})
it('should build and export', async () => {
await nextBuild(appDir)
await nextExportDefault(appDir, { ignoreFail: true })
})
it('should have the expected outputs for export', () => {
expect(
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8'))
).toMatchInlineSnapshot(`
it('should have the expected outputs for export', () => {
expect(
JSON.parse(
fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')
)
).toMatchInlineSnapshot(`
Object {
"exportTrailingSlash": false,
"hasExportPathMap": false,
@ -156,38 +179,45 @@ describe('Application Export Intent Output', () => {
}
`)
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
const detail = JSON.parse(
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
)
expect({
...detail,
outDirectory: path.basename(detail.outDirectory),
}).toMatchInlineSnapshot(`
Object {
"outDirectory": "out",
"success": false,
"version": 1,
}
`)
})
})
}
)
})
describe('No Export', () => {
const appDir = join(fixturesDir, 'no-export')
const distDir = join(appDir, '.next')
;(process.env.TURBOPACK ? describe.skip : describe)(
'production mode',
() => {
const appDir = join(fixturesDir, 'no-export')
const distDir = join(appDir, '.next')
beforeAll(async () => {
await remove(distDir)
})
beforeAll(async () => {
await remove(distDir)
})
it('should build and not export', async () => {
await nextBuild(appDir)
})
it('should build and not export', async () => {
await nextBuild(appDir)
})
it('should have the expected outputs for export', () => {
expect(
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8'))
).toMatchInlineSnapshot(`
it('should have the expected outputs for export', () => {
expect(
JSON.parse(
fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')
)
).toMatchInlineSnapshot(`
Object {
"exportTrailingSlash": false,
"hasExportPathMap": false,
@ -196,25 +226,27 @@ describe('Application Export Intent Output', () => {
}
`)
expect(() => {
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
}).toThrowError(/ENOENT/)
})
expect(() => {
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
}).toThrowError(/ENOENT/)
})
it('should export and create file', async () => {
await nextExportDefault(appDir)
it('should export and create file', async () => {
await nextExportDefault(appDir)
expect(() => {
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
}).not.toThrow()
})
expect(() => {
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
}).not.toThrow()
})
it('should build and clean up', async () => {
await nextBuild(appDir)
it('should build and clean up', async () => {
await nextBuild(appDir)
expect(() => {
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
}).toThrowError(/ENOENT/)
})
expect(() => {
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8')
}).toThrowError(/ENOENT/)
})
}
)
})
})

View file

@ -15,29 +15,31 @@ let appPort
let app
describe("Handle ESM externals with esmExternals: 'loose'", () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
const expected =
/Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World/
const expected =
/Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World/
it('should render the static page', async () => {
const html = await renderViaHTTP(appPort, '/static')
expect(html).toMatch(expected)
})
it('should render the static page', async () => {
const html = await renderViaHTTP(appPort, '/static')
expect(html).toMatch(expected)
})
it('should render the ssr page', async () => {
const html = await renderViaHTTP(appPort, '/ssr')
expect(html).toMatch(expected)
})
it('should render the ssr page', async () => {
const html = await renderViaHTTP(appPort, '/ssr')
expect(html).toMatch(expected)
})
it('should render the ssg page', async () => {
const html = await renderViaHTTP(appPort, '/ssg')
expect(html).toMatch(expected)
it('should render the ssg page', async () => {
const html = await renderViaHTTP(appPort, '/ssg')
expect(html).toMatch(expected)
})
})
})

View file

@ -15,29 +15,31 @@ let appPort
let app
describe('Handle ESM externals with esmExternals: true', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
const expected =
/Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World\+World\+World/
const expected =
/Hello <!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World<!-- -->\+<!-- -->World\+World\+World/
it('should render the static page', async () => {
const html = await renderViaHTTP(appPort, '/static')
expect(html).toMatch(expected)
})
it('should render the static page', async () => {
const html = await renderViaHTTP(appPort, '/static')
expect(html).toMatch(expected)
})
it('should render the ssr page', async () => {
const html = await renderViaHTTP(appPort, '/ssr')
expect(html).toMatch(expected)
})
it('should render the ssr page', async () => {
const html = await renderViaHTTP(appPort, '/ssr')
expect(html).toMatch(expected)
})
it('should render the ssg page', async () => {
const html = await renderViaHTTP(appPort, '/ssg')
expect(html).toMatch(expected)
it('should render the ssg page', async () => {
const html = await renderViaHTTP(appPort, '/ssg')
expect(html).toMatch(expected)
})
})
})

View file

@ -13,10 +13,11 @@ const writePage = async (content, testPage = join(pagesDir, 'test.js')) => {
}
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 () => {
await writePage(`
it('should fail build from module not found', async () => {
await writePage(`
__non_webpack_require__('a-cool-module')
export function getStaticProps() {
@ -29,13 +30,13 @@ describe('GSP build errors', () => {
return null
}
`)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a-cool-module')
})
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a-cool-module')
})
it('should fail build from ENOENT in getStaticProps', async () => {
await writePage(`
it('should fail build from ENOENT in getStaticProps', async () => {
await writePage(`
export function getStaticProps() {
require('fs').readFileSync('a-cool-file')
@ -48,13 +49,13 @@ describe('GSP build errors', () => {
return null
}
`)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a-cool-file')
})
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a-cool-file')
})
it('should fail build on normal error in getStaticProps', async () => {
await writePage(`
it('should fail build on normal error in getStaticProps', async () => {
await writePage(`
export function getStaticProps() {
throw new Error('a cool error')
return {
@ -66,13 +67,13 @@ describe('GSP build errors', () => {
return null
}
`)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a cool error')
})
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a cool error')
})
it('should fail build from undefined error in getStaticProps', async () => {
await writePage(`
it('should fail build from undefined error in getStaticProps', async () => {
await writePage(`
export function getStaticProps() {
throw undefined
return {
@ -84,13 +85,13 @@ describe('GSP build errors', () => {
return null
}
`)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('undefined')
})
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('undefined')
})
it('should fail build from string error in getStaticProps', async () => {
await writePage(`
it('should fail build from string error in getStaticProps', async () => {
await writePage(`
export function getStaticProps() {
throw 'a string error'
return {
@ -102,13 +103,13 @@ describe('GSP build errors', () => {
return null
}
`)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a string error')
})
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('a string error')
})
it('should handle non-serializable error in getStaticProps', async () => {
await writePage(`
it('should handle non-serializable error in getStaticProps', async () => {
await writePage(`
export function getStaticProps() {
const err = new Error('my custom error')
err.hello = 'world'
@ -127,14 +128,14 @@ describe('GSP build errors', () => {
return null
}
`)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('my custom error')
})
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('my custom error')
})
it('should handle non-serializable error in getStaticPaths', async () => {
await writePage(
`
it('should handle non-serializable error in getStaticPaths', async () => {
await writePage(
`
export function getStaticProps() {
return {
props: {}
@ -160,10 +161,11 @@ describe('GSP build errors', () => {
return null
}
`,
join(pagesDir, '[slug].js')
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('my custom error')
join(pagesDir, '[slug].js')
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(code).toBe(1)
expect(stderr).toContain('my custom error')
})
})
})

View file

@ -107,7 +107,7 @@ const runTests = () => {
})
}
describe('Custom routes i18n', () => {
describe('Custom routes i18n custom error', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()

View file

@ -75,7 +75,7 @@ const runTests = () => {
})
}
describe('Custom routes i18n', () => {
describe('Custom routes i18n support index rewrite', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()

View file

@ -89,20 +89,22 @@ const runTests = (isDev = false) => {
}
describe('Build Error Tests for basePath', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
})
})
})
describe('Static Image Component Tests for basePath', () => {

View file

@ -99,34 +99,38 @@ const runTests = () => {
}
describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
})
})
})
describe('Static Image Component Tests', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
html = await renderViaHTTP(appPort, '/static-img')
browser = await webdriver(appPort, '/static-img')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
html = await renderViaHTTP(appPort, '/static-img')
browser = await webdriver(appPort, '/static-img')
})
afterAll(() => {
killApp(app)
})
runTests()
})
afterAll(() => {
killApp(app)
})
runTests()
})

View file

@ -186,22 +186,24 @@ const runTests = (isDev) => {
}
describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../../public/foo/test-rect.jpg',
'../../public/foo/test-rect-broken.jpg'
)
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../../public/foo/test-rect.jpg',
'../../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
expect(stderr).toContain(
"Module not found: Can't resolve '../../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./app/static-img/page.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
expect(stderr).toContain(
"Module not found: Can't resolve '../../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./app/static-img/page.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
})
})
})
describe('Static Image Component Tests', () => {

View file

@ -144,22 +144,24 @@ const runTests = (isDev) => {
}
describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
})
})
})
describe('Static Image Component Tests for basePath', () => {

View file

@ -198,22 +198,24 @@ const runTests = (isDev) => {
}
describe('Build Error Tests', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
it('should throw build error when import statement is used with missing file', async () => {
await indexPage.replace(
'../public/foo/test-rect.jpg',
'../public/foo/test-rect-broken.jpg'
)
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
await indexPage.restore()
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
expect(stderr).toContain(
"Module not found: Can't resolve '../public/foo/test-rect-broken.jpg"
)
// should contain the importing module
expect(stderr).toContain('./pages/static-img.js')
// should contain a import trace
expect(stderr).not.toContain('Import trace for requested module')
})
})
})
describe('Static Image Component Tests', () => {

View file

@ -15,18 +15,19 @@ const addPage = async (page, content) => {
}
describe('no-op export', () => {
afterEach(async () => {
await Promise.all(
['.next', 'pages', 'next.config.js', 'out'].map((file) =>
fs.remove(join(appDir, file))
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterEach(async () => {
await Promise.all(
['.next', 'pages', 'next.config.js', 'out'].map((file) =>
fs.remove(join(appDir, file))
)
)
)
})
})
it('should not error for all server-side pages build', async () => {
await addPage(
'_error.js',
`
it('should not error for all server-side pages build', async () => {
await addPage(
'_error.js',
`
import React from 'react'
export default class Error extends React.Component {
static async getInitialProps() {
@ -41,10 +42,10 @@ describe('no-op export', () => {
}
}
`
)
await addPage(
'[slug].js',
`
)
await addPage(
'[slug].js',
`
export const getStaticProps = () => {
return {
props: {}
@ -60,42 +61,43 @@ describe('no-op export', () => {
return 'page'
}
`
)
const result = await nextBuild(appDir, undefined, {
stderr: 'log',
stdout: 'log',
)
const result = await nextBuild(appDir, undefined, {
stderr: 'log',
stdout: 'log',
})
expect(result.code).toBe(0)
})
expect(result.code).toBe(0)
})
it('should not error for empty exportPathMap', async () => {
await addPage(
'index.js',
`
it('should not error for empty exportPathMap', async () => {
await addPage(
'index.js',
`
export default function Index() {
return 'hello world'
}
`
)
await fs.writeFile(
nextConfig,
`
)
await fs.writeFile(
nextConfig,
`
module.exports = {
exportPathMap() {
return {}
}
}
`
)
const buildResult = await nextBuild(appDir, undefined, {
stderr: 'log',
stdout: 'log',
})
expect(buildResult.code).toBe(0)
)
const buildResult = await nextBuild(appDir, undefined, {
stderr: 'log',
stdout: 'log',
})
expect(buildResult.code).toBe(0)
const exportResult = await nextExport(appDir, {
outdir: join(appDir, 'out'),
const exportResult = await nextExport(appDir, {
outdir: join(appDir, 'out'),
})
expect(exportResult.code).toBe(0)
})
expect(exportResult.code).toBe(0)
})
})

View file

@ -28,7 +28,8 @@ const startServer = async (optEnv = {}, opts) => {
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', () => {})
beforeAll(async () => {
await startServer()

View file

@ -7,15 +7,17 @@ import { join } from 'path'
const appDir = join(__dirname, '../')
describe('Polyfilling (minimal)', () => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
})

View file

@ -10,45 +10,47 @@ let appPort
let app
describe('Polyfills', () => {
let output = ''
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
let output = ''
beforeAll(async () => {
const { stdout, stderr } = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
beforeAll(async () => {
const { stdout, stderr } = await nextBuild(appDir, [], {
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 () => {
const browser = await webdriver(appPort, '/fetch')
const text = await browser.elementByCss('#test-status').text()
it('should alias fetch', async () => {
const browser = await webdriver(appPort, '/fetch')
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 () => {
const browser = await webdriver(appPort, '/process')
const text = await browser.elementByCss('#process').text()
it('should allow using process.env when there is an element with `id` of `process`', async () => {
const browser = await webdriver(appPort, '/process')
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 () => {
expect(output).toContain('Generating static pages (0/5)')
expect(output).toContain('Generating static pages (5/5)')
// we should only have 1 segment and the initial message logged out
expect(output.match(/Generating static pages/g).length).toBe(5)
it('should contain generated page count in output', async () => {
expect(output).toContain('Generating static pages (0/5)')
expect(output).toContain('Generating static pages (5/5)')
// we should only have 1 segment and the initial message logged out
expect(output.match(/Generating static pages/g).length).toBe(5)
})
})
})

View file

@ -7,84 +7,92 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'scss-fixtures')
describe('Invalid CSS in _document', () => {
const appDir = join(fixturesDir, 'invalid-module-document')
describe('Invalid SCSS in _document', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-module-document')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
const appDir = join(fixturesDir, 'invalid-global')
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
const appDir = join(fixturesDir, 'invalid-global')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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', () => {
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 () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], {
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/)
})
})

View file

@ -65,7 +65,9 @@ describe('turbopack unsupported features log', () => {
await fs.writeFile(
nextConfigPath,
`module.exports = {
assetPrefix: '/idk'
experimental: {
urlImports: true
}
}`
)
const appPort = await findPort()
@ -91,6 +93,6 @@ describe('turbopack unsupported features log', () => {
}
})
} else {
it.skip('turobpack only', () => {})
it.skip('turbopack only', () => {})
}
})

View file

@ -3,10 +3,14 @@ import { nextBuild } from 'next-test-utils'
const appDir = join(__dirname, '../')
describe('webpack config with extensionAlias setting', () => {
it('should run correctly with an tsx file import with .js extension', async () => {
const { code } = await nextBuild(appDir, [], {})
// Skip webpack specific test in Turbopack
;(process.env.TURBOPACK ? describe.skip : describe)(
'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)
})
}
)

View file

@ -996,7 +996,9 @@ export function runProdSuite(
env?: NodeJS.ProcessEnv
}
) {
return runSuite(suiteName, { appDir, env: 'prod' }, options)
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runSuite(suiteName, { appDir, env: 'prod' }, options)
})
}
/**