diff --git a/test/development/webpack-issuer-deprecation-warning/index.test.ts b/test/development/webpack-issuer-deprecation-warning/index.test.ts index 4951405b8f..f74f9bc38c 100644 --- a/test/development/webpack-issuer-deprecation-warning/index.test.ts +++ b/test/development/webpack-issuer-deprecation-warning/index.test.ts @@ -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

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' + ) + }) + } +) diff --git a/test/integration/css-features/test/browserslist.test.js b/test/integration/css-features/test/browserslist.test.js index 2fbf1d1190..6966c72eba 100644 --- a/test/integration/css-features/test/browserslist.test.js +++ b/test/integration/css-features/test/browserslist.test.js @@ -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==)}}"` + ) + }) }) }) diff --git a/test/integration/css-features/test/css-modules.test.js b/test/integration/css-features/test/css-modules.test.js index 07eaf22e84..c22a3a7891 100644 --- a/test/integration/css-features/test/css-modules.test.js +++ b/test/integration/css-features/test/css-modules.test.js @@ -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}"`) + }) }) }) diff --git a/test/integration/css-features/test/index.test.js b/test/integration/css-features/test/index.test.js index d7eb6b0e73..a5c2982e35 100644 --- a/test/integration/css-features/test/index.test.js +++ b/test/integration/css-features/test/index.test.js @@ -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}"`) + }) }) }) diff --git a/test/integration/css/test/valid-invalid-css.test.js b/test/integration/css/test/valid-invalid-css.test.js index 6e1ee3da36..9e1240ce57 100644 --- a/test/integration/css/test/valid-invalid-css.test.js +++ b/test/integration/css/test/valid-invalid-css.test.js @@ -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/) }) }) diff --git a/test/integration/error-plugin-stack-overflow/test/index.test.js b/test/integration/error-plugin-stack-overflow/test/index.test.js index 6ea085d2df..e442996223 100644 --- a/test/integration/error-plugin-stack-overflow/test/index.test.js +++ b/test/integration/error-plugin-stack-overflow/test/index.test.js @@ -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') - }) -}) + } +) diff --git a/test/integration/export-image-loader/test/index.test.js b/test/integration/export-image-loader/test/index.test.js index be3db688fa..8daa5e1249 100644 --- a/test/integration/export-image-loader/test/index.test.js +++ b/test/integration/export-image-loader/test/index.test.js @@ -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() + }) }) }) diff --git a/test/integration/export-intent/test/index.test.js b/test/integration/export-intent/test/index.test.js index 0fd404bca7..61b2e7c7d2 100644 --- a/test/integration/export-intent/test/index.test.js +++ b/test/integration/export-intent/test/index.test.js @@ -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/) + }) + } + ) }) }) diff --git a/test/integration/externals-esm-loose/test/index.test.js b/test/integration/externals-esm-loose/test/index.test.js index 38baa438a7..484af148d0 100644 --- a/test/integration/externals-esm-loose/test/index.test.js +++ b/test/integration/externals-esm-loose/test/index.test.js @@ -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) + }) }) }) diff --git a/test/integration/externals-esm/test/index.test.js b/test/integration/externals-esm/test/index.test.js index 98d2804d72..5ab13a2f71 100644 --- a/test/integration/externals-esm/test/index.test.js +++ b/test/integration/externals-esm/test/index.test.js @@ -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) + }) }) }) diff --git a/test/integration/gsp-build-errors/test/index.test.js b/test/integration/gsp-build-errors/test/index.test.js index 2536576acb..1de41fc18f 100644 --- a/test/integration/gsp-build-errors/test/index.test.js +++ b/test/integration/gsp-build-errors/test/index.test.js @@ -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') + }) }) }) diff --git a/test/integration/i18n-support-custom-error/test/index.test.js b/test/integration/i18n-support-custom-error/test/index.test.js index cadd15d9c9..46ff4642b1 100644 --- a/test/integration/i18n-support-custom-error/test/index.test.js +++ b/test/integration/i18n-support-custom-error/test/index.test.js @@ -107,7 +107,7 @@ const runTests = () => { }) } -describe('Custom routes i18n', () => { +describe('Custom routes i18n custom error', () => { describe('dev mode', () => { beforeAll(async () => { appPort = await findPort() diff --git a/test/integration/i18n-support-index-rewrite/test/index.test.js b/test/integration/i18n-support-index-rewrite/test/index.test.js index 6ac3afaad8..8612f60c45 100644 --- a/test/integration/i18n-support-index-rewrite/test/index.test.js +++ b/test/integration/i18n-support-index-rewrite/test/index.test.js @@ -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() diff --git a/test/integration/next-image-legacy/base-path/test/static.test.ts b/test/integration/next-image-legacy/base-path/test/static.test.ts index bd3d7c62d5..4e18e26fce 100644 --- a/test/integration/next-image-legacy/base-path/test/static.test.ts +++ b/test/integration/next-image-legacy/base-path/test/static.test.ts @@ -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', () => { diff --git a/test/integration/next-image-legacy/default/test/static.test.ts b/test/integration/next-image-legacy/default/test/static.test.ts index cfde0c0216..502d87d8c1 100644 --- a/test/integration/next-image-legacy/default/test/static.test.ts +++ b/test/integration/next-image-legacy/default/test/static.test.ts @@ -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() }) diff --git a/test/integration/next-image-new/app-dir/test/static.test.ts b/test/integration/next-image-new/app-dir/test/static.test.ts index 8a2d19ea9a..0d2379e2f3 100644 --- a/test/integration/next-image-new/app-dir/test/static.test.ts +++ b/test/integration/next-image-new/app-dir/test/static.test.ts @@ -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', () => { diff --git a/test/integration/next-image-new/base-path/test/static.test.js b/test/integration/next-image-new/base-path/test/static.test.js index fda3e25882..9d671a7c3b 100644 --- a/test/integration/next-image-new/base-path/test/static.test.js +++ b/test/integration/next-image-new/base-path/test/static.test.js @@ -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', () => { diff --git a/test/integration/next-image-new/default/test/static.test.ts b/test/integration/next-image-new/default/test/static.test.ts index af3a023fed..35265a47de 100644 --- a/test/integration/next-image-new/default/test/static.test.ts +++ b/test/integration/next-image-new/default/test/static.test.ts @@ -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', () => { diff --git a/test/integration/no-op-export/test/index.test.js b/test/integration/no-op-export/test/index.test.js index 2cb5855b6a..6e939318e3 100644 --- a/test/integration/no-op-export/test/index.test.js +++ b/test/integration/no-op-export/test/index.test.js @@ -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) }) }) diff --git a/test/integration/ondemand/test/index.test.js b/test/integration/ondemand/test/index.test.js index d6457a33d7..d1267d8ffc 100644 --- a/test/integration/ondemand/test/index.test.js +++ b/test/integration/ondemand/test/index.test.js @@ -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() diff --git a/test/integration/polyfilling-minimal/test/index.test.js b/test/integration/polyfilling-minimal/test/index.test.js index 633664eb3e..70ac86ce9a 100644 --- a/test/integration/polyfilling-minimal/test/index.test.js +++ b/test/integration/polyfilling-minimal/test/index.test.js @@ -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/) }) }) diff --git a/test/integration/polyfills/test/index.test.js b/test/integration/polyfills/test/index.test.js index 48734881d9..bbb9959327 100644 --- a/test/integration/polyfills/test/index.test.js +++ b/test/integration/polyfills/test/index.test.js @@ -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) + }) }) }) diff --git a/test/integration/scss/test/valid-invalid-scss.test.js b/test/integration/scss/test/valid-invalid-scss.test.js index bf218d1b0b..49a0472a31 100644 --- a/test/integration/scss/test/valid-invalid-scss.test.js +++ b/test/integration/scss/test/valid-invalid-scss.test.js @@ -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/) }) }) diff --git a/test/integration/turbopack-unsupported-log/index.test.ts b/test/integration/turbopack-unsupported-log/index.test.ts index 6a1ef27a62..10019ccc44 100644 --- a/test/integration/turbopack-unsupported-log/index.test.ts +++ b/test/integration/turbopack-unsupported-log/index.test.ts @@ -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', () => {}) } }) diff --git a/test/integration/webpack-config-extensionalias/test/index.test.js b/test/integration/webpack-config-extensionalias/test/index.test.js index c6eada16f8..49443f91a8 100644 --- a/test/integration/webpack-config-extensionalias/test/index.test.js +++ b/test/integration/webpack-config-extensionalias/test/index.test.js @@ -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) + }) + } +) diff --git a/test/lib/next-test-utils.ts b/test/lib/next-test-utils.ts index b294275732..7cc38b7b07 100644 --- a/test/lib/next-test-utils.ts +++ b/test/lib/next-test-utils.ts @@ -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) + }) } /**