Unverified Commit d3499931 authored by Jamiboy Mohammad's avatar Jamiboy Mohammad Committed by GitHub

test: enable deploy coverage for asset and compiler errors (#98850)

## Summary
Enable deployment coverage for 15 asset/compiler exclusion locations
using the deferred deployment lifecycle from #98776. Replace local-only
build calls with explicit start/failure assertions and retain the
expected image, Sass, loader, foreign-package, and missing-dependency
diagnostics. Preserve the existing development-only and bundler-specific
exclusions.

## Verification
- All applicable focused Turbopack production/development and Webpack
production checks passed.
- Local checks used the published native binding. Exact native and
deploy validation are pending repository CI.

<!-- NEXT_JS_LLM -->

---------
Co-authored-by: 's avatarClaude Opus 5 <noreply@anthropic.com>
parent ef0d79f5
...@@ -28,19 +28,16 @@ describe('Error test if the loader file export a named function', () => { ...@@ -28,19 +28,16 @@ describe('Error test if the loader file export a named function', () => {
}) })
}) })
// @force-gate !dev
describe('in Build and Start', () => { describe('in Build and Start', () => {
const { next, isNextStart } = nextTestSetup({ const { next } = nextTestSetup({
skipStart: true, skipStart: true,
files: __dirname, files: __dirname,
}) })
;(isNextStart ? describe : describe.skip)('build and start only', () => { it('should show the build error', async () => {
it('should show the build error', async () => { await expect(next.start()).rejects.toThrow()
await expect(next.start()).rejects.toThrow( expect(next.cliOutput).toContain(errorMessage)
'next build failed with code/signal 1' }, 240_000)
)
expect(next.cliOutput).toContain(errorMessage)
})
})
}) })
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('metadata-invalid-image-file', () => { describe('metadata-invalid-image-file', () => {
const { next, isTurbopack, isNextDev, skipped, isRspack } = nextTestSetup({ const { next, isTurbopack, isNextDev, isRspack } = nextTestSetup({
files: __dirname, files: __dirname,
skipDeployment: true,
skipStart: true, skipStart: true,
}) })
if (skipped) return
it('should error on invalid metadata image file', async () => { it('should error on invalid metadata image file', async () => {
// In dev, it needs to render the page first // In dev, it needs to render the page first
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
await next.fetch('/') await next.fetch('/')
} else { } else {
await next.build() await expect(next.start()).rejects.toThrow()
} }
if (isTurbopack) { if (isTurbopack) {
...@@ -43,5 +40,5 @@ describe('metadata-invalid-image-file', () => { ...@@ -43,5 +40,5 @@ describe('metadata-invalid-image-file', () => {
) )
} }
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('next-image-legacy-src-with-query-without-local-patterns', () => { describe('next-image-legacy-src-with-query-without-local-patterns', () => {
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev, isNextDeploy } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
}) })
if (skipped) {
return
}
it('should throw error for relative image with query without localPatterns for legacy Image', async () => { it('should throw error for relative image with query without localPatterns for legacy Image', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
...@@ -19,10 +14,17 @@ describe('next-image-legacy-src-with-query-without-local-patterns', () => { ...@@ -19,10 +14,17 @@ describe('next-image-legacy-src-with-query-without-local-patterns', () => {
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
// Deployment build logs prefix each line with an ISO timestamp.
const cliOutput = isNextDeploy
? next.cliOutput.replace(
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z {2}/gm,
''
)
: next.cliOutput
expect(cliOutput).toContain( expect(cliOutput).toContain(
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('next-image-src-with-query-without-local-patterns', () => { describe('next-image-src-with-query-without-local-patterns', () => {
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
}) })
if (skipped) {
return
}
it('should throw error for relative image with query without localPatterns', async () => { it('should throw error for relative image with query without localPatterns', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
...@@ -19,10 +14,11 @@ describe('next-image-src-with-query-without-local-patterns', () => { ...@@ -19,10 +14,11 @@ describe('next-image-src-with-query-without-local-patterns', () => {
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
const cliOutput = next.cliOutput
expect(cliOutput).toContain( expect(cliOutput).toContain(
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} }
}) }, 240_000)
}) })
/* eslint-env jest */ /* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils' import { isNextDev, nextTestSetup } from 'e2e-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('Invalid Global CSS with Custom App', () => { describe('Invalid Global CSS with Custom App', () => {
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: isNextStart, skipStart: !isNextDev,
skipDeployment: true,
dependencies: { sass: '1.54.0' }, dependencies: { sass: '1.54.0' },
}) })
if (skipped) { if (!isNextDev) {
return
}
if (isNextStart) {
it('should fail to build', async () => { it('should fail to build', async () => {
const { exitCode, cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
expect(exitCode).not.toBe(0) const cliOutput = next.cliOutput
if (!isTurbopack) { if (!isTurbopack) {
expect(cliOutput).toContain('Failed to compile') expect(cliOutput).toContain('Failed to compile')
} }
...@@ -30,7 +26,7 @@ describe('Invalid Global CSS with Custom App', () => { ...@@ -30,7 +26,7 @@ describe('Invalid Global CSS with Custom App', () => {
if (!process.env.NEXT_RSPACK) { if (!process.env.NEXT_RSPACK) {
expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/) expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/)
} }
}) }, 240_000)
} else { } else {
it('should show a build error', async () => { it('should show a build error', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
......
/* eslint-env jest */ /* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils' import { isNextDev, nextTestSetup } from 'e2e-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('Invalid Global CSS', () => { describe('Invalid Global CSS', () => {
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: isNextStart, skipStart: !isNextDev,
skipDeployment: true,
dependencies: { sass: '1.54.0' }, dependencies: { sass: '1.54.0' },
}) })
if (skipped) { if (!isNextDev) {
return
}
if (isNextStart) {
it('should fail to build', async () => { it('should fail to build', async () => {
const { exitCode, cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
expect(exitCode).not.toBe(0) const cliOutput = next.cliOutput
if (!isTurbopack) { if (!isTurbopack) {
expect(cliOutput).toContain('Failed to compile') expect(cliOutput).toContain('Failed to compile')
} }
...@@ -30,7 +26,7 @@ describe('Invalid Global CSS', () => { ...@@ -30,7 +26,7 @@ describe('Invalid Global CSS', () => {
if (!process.env.NEXT_RSPACK) { if (!process.env.NEXT_RSPACK) {
expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/) expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/)
} }
}) }, 240_000)
} else { } else {
it('should show a build error', async () => { it('should show a build error', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
......
/* eslint-env jest */ /* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils' import { isNextDev, nextTestSetup } from 'e2e-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils'
// Importing module CSS in _document is allowed in Turbopack // Importing module CSS in _document is allowed in Turbopack
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( ;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Invalid SCSS in _document', 'Invalid SCSS in _document',
() => { () => {
const { next, skipped, isRspack } = nextTestSetup({ const { next, isRspack } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: isNextStart, skipStart: !isNextDev,
skipDeployment: true,
dependencies: { sass: '1.54.0' }, dependencies: { sass: '1.54.0' },
}) })
if (skipped) { if (!isNextDev) {
return
}
if (isNextStart) {
it('should fail to build', async () => { it('should fail to build', async () => {
const { exitCode, cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
expect(exitCode).not.toBe(0) const cliOutput = next.cliOutput
expect(cliOutput).toContain('Failed to compile') expect(cliOutput).toContain('Failed to compile')
expect(cliOutput).toContain('styles.module.scss') expect(cliOutput).toContain('styles.module.scss')
expect(cliOutput).toMatch( expect(cliOutput).toMatch(
...@@ -31,7 +27,7 @@ import { waitForRedbox, getRedboxSource } from 'next-test-utils' ...@@ -31,7 +27,7 @@ import { waitForRedbox, getRedboxSource } from 'next-test-utils'
if (!process.env.NEXT_RSPACK) { if (!process.env.NEXT_RSPACK) {
expect(cliOutput).toMatch(/Location:.*pages[\\/]_document\.js/) expect(cliOutput).toMatch(/Location:.*pages[\\/]_document\.js/)
} }
}) }, 240_000)
} else { } else {
it('should show a build error', async () => { it('should show a build error', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
......
/* eslint-env jest */ /* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils' import { isNextDev, nextTestSetup } from 'e2e-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('CSS Import from node_modules', () => { describe('CSS Import from node_modules', () => {
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: isNextStart, skipStart: !isNextDev,
skipDeployment: true,
dependencies: { sass: '1.54.0' }, dependencies: { sass: '1.54.0' },
}) })
if (skipped) { if (!isNextDev) {
return
}
if (isNextStart) {
it('should fail the build', async () => { it('should fail the build', async () => {
const { exitCode, cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
expect(exitCode).not.toBe(0) const cliOutput = next.cliOutput
if (isRspack) { if (isRspack) {
expect(cliOutput).toMatch( expect(cliOutput).toMatch(
/RspackResolver\(NotFound\(\\?"nprogress\/nprogress.css\\?"\)\)/ /RspackResolver\(NotFound\(\\?"nprogress\/nprogress.css\\?"\)\)/
...@@ -27,7 +23,7 @@ describe('CSS Import from node_modules', () => { ...@@ -27,7 +23,7 @@ describe('CSS Import from node_modules', () => {
expect(cliOutput).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/) expect(cliOutput).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/)
} }
expect(cliOutput).toMatch(/Build failed|Build error occurred/) expect(cliOutput).toMatch(/Build failed|Build error occurred/)
}) }, 240_000)
} else { } else {
it('should show a build error', async () => { it('should show a build error', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
......
/* eslint-env jest */ /* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils' import { isNextDev, nextTestSetup } from 'e2e-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils' import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('Valid and Invalid Global CSS with Custom App', () => { describe('Valid and Invalid Global CSS with Custom App', () => {
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({ const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: isNextStart, skipStart: !isNextDev,
skipDeployment: true,
dependencies: { sass: '1.54.0' }, dependencies: { sass: '1.54.0' },
}) })
if (skipped) { if (!isNextDev) {
return
}
if (isNextStart) {
it('should fail to build', async () => { it('should fail to build', async () => {
const { exitCode, cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
expect(exitCode).not.toBe(0) const cliOutput = next.cliOutput
if (!isTurbopack) { if (!isTurbopack) {
expect(cliOutput).toContain('Failed to compile') expect(cliOutput).toContain('Failed to compile')
} }
...@@ -30,7 +26,7 @@ describe('Valid and Invalid Global CSS with Custom App', () => { ...@@ -30,7 +26,7 @@ describe('Valid and Invalid Global CSS with Custom App', () => {
if (!process.env.NEXT_RSPACK) { if (!process.env.NEXT_RSPACK) {
expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/) expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/)
} }
}) }, 240_000)
} else { } else {
it('should show a build error', async () => { it('should show a build error', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
......
...@@ -5,13 +5,12 @@ describe('SCSS Support', () => { ...@@ -5,13 +5,12 @@ describe('SCSS Support', () => {
const { next, isNextDev } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
}) })
// Production only test // Production only test
;(isNextDev ? describe.skip : describe)('Friendly Webpack Error', () => { ;(isNextDev ? describe.skip : describe)('Friendly Webpack Error', () => {
it('should be a friendly error successfully', async () => { it('should be a friendly error successfully', async () => {
const { exitCode, cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
expect(exitCode).toBe(1) const cliOutput = next.cliOutput
expect(cliOutput).toContain('./styles/global.scss') expect(cliOutput).toContain('./styles/global.scss')
expect(cliOutput).toContain( expect(cliOutput).toContain(
...@@ -26,6 +25,6 @@ describe('SCSS Support', () => { ...@@ -26,6 +25,6 @@ describe('SCSS Support', () => {
expect(cliOutput).not.toContain('css-loader') expect(cliOutput).not.toContain('css-loader')
expect(cliOutput).not.toContain('sass-loader') expect(cliOutput).not.toContain('sass-loader')
}) }, 240_000)
}) })
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('next-image-legacy-src-with-query-without-local-patterns', () => { describe('next-image-legacy-src-with-query-without-local-patterns', () => {
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
}) })
if (skipped) {
return
}
it('should throw error for relative image with query without localPatterns for legacy Image', async () => { it('should throw error for relative image with query without localPatterns for legacy Image', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
...@@ -19,10 +14,11 @@ describe('next-image-legacy-src-with-query-without-local-patterns', () => { ...@@ -19,10 +14,11 @@ describe('next-image-legacy-src-with-query-without-local-patterns', () => {
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
const cliOutput = next.cliOutput
expect(cliOutput).toContain( expect(cliOutput).toContain(
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('next-image-src-with-query-without-local-patterns', () => { describe('next-image-src-with-query-without-local-patterns', () => {
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
}) })
if (skipped) {
return
}
it('should throw error for relative image with query without localPatterns', async () => { it('should throw error for relative image with query without localPatterns', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
...@@ -19,10 +14,11 @@ describe('next-image-src-with-query-without-local-patterns', () => { ...@@ -19,10 +14,11 @@ describe('next-image-src-with-query-without-local-patterns', () => {
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
const cliOutput = next.cliOutput
expect(cliOutput).toContain( expect(cliOutput).toContain(
'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns' 'Image with src "/test.png?v=1" is using a query string which is not configured in images.localPatterns.\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns'
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { join } from 'path' import { join } from 'path'
// @force-gate !dev
describe('script-loader - partytown-missing', () => { describe('script-loader - partytown-missing', () => {
const { next, isNextDev } = nextTestSetup({ const { next, isNextDeploy } = nextTestSetup({
files: join(__dirname, 'partytown-missing'), files: join(__dirname, 'partytown-missing'),
skipStart: true, skipStart: true,
// Vercel deployment fails to build/deploy this fixture in CI; skip in deploy mode.
skipDeployment: true,
}) })
it('Error message is shown if Partytown is not installed locally', async () => { it('Error message is shown if Partytown is not installed locally', async () => {
if (isNextDev) return await expect(next.start()).rejects.toThrow()
// Deployment build logs prefix each line with an ISO timestamp.
const { cliOutput } = await next.build() const cliOutput = isNextDeploy
? next.cliOutput.replace(
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z {2}/gm,
''
)
: next.cliOutput
expect(cliOutput.replace(/[\n\r]/g, '')).toMatch( expect(cliOutput.replace(/[\n\r]/g, '')).toMatch(
/It looks like you're trying to use Partytown with next\/script but do not have the required package\(s\) installed.Please install Partytown by running:.*?(npm|pnpm|yarn) (install|add) (--save-dev|--dev) @builder\.io\/partytownIf you are not trying to use Partytown, please disable the experimental "nextScriptWorkers" flag in next\.config\.js\./ /It looks like you're trying to use Partytown with next\/script but do not have the required package\(s\) installed.Please install Partytown by running:.*?(npm|pnpm|yarn) (install|add) (--save-dev|--dev) @builder\.io\/partytownIf you are not trying to use Partytown, please disable the experimental "nextScriptWorkers" flag in next\.config\.js\./
) )
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// vercel.json uses pnpm so file: dependencies are installed inside node_modules.
// npm links them to fixture source, which is transpiled without transpilePackages.
describe('transpile-packages-typescript-foreign', () => { describe('transpile-packages-typescript-foreign', () => {
describe('without transpilePackages', () => { describe('without transpilePackages', () => {
const { next, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipDeployment: true,
skipStart: true, skipStart: true,
// Use the fixture's packageManager version rather than Vercel's default pnpm.
env: { ENABLE_EXPERIMENTAL_COREPACK: '1' },
dependencies: { dependencies: {
pkg: `file:./pkg`, pkg: `file:./pkg`,
}, },
}) })
if (skipped) {
return
}
it('should fail', async () => { it('should fail', async () => {
try { if (isNextDev) {
await next.start() try {
await next.render('/') await next.start()
} catch (e) {} await next.render('/')
} catch {}
} else {
await expect(next.start()).rejects.toThrow()
}
if (process.env.IS_TURBOPACK_TEST) { if (process.env.IS_TURBOPACK_TEST) {
expect(next.cliOutput).toContain(`pkg/index.ts expect(next.cliOutput).toContain(`pkg/index.ts
...@@ -35,12 +38,13 @@ This module doesn't have an associated type`) ...@@ -35,12 +38,13 @@ This module doesn't have an associated type`)
expect(next.cliOutput).toContain(`pkg/index.ts expect(next.cliOutput).toContain(`pkg/index.ts
Module parse failed: Unexpected token`) Module parse failed: Unexpected token`)
} }
}) }, 240_000)
}) })
describe('with transpilePackages', () => { describe('with transpilePackages', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
env: { ENABLE_EXPERIMENTAL_COREPACK: '1' },
dependencies: { dependencies: {
pkg: `file:./pkg`, pkg: `file:./pkg`,
}, },
......
...@@ -75,18 +75,12 @@ function extractErrorBlock(output: string, errorTitle: string): string { ...@@ -75,18 +75,12 @@ function extractErrorBlock(output: string, errorTitle: string): string {
return block.trimEnd() return block.trimEnd()
} }
// @force-gate dev
describe('webpack-loader-parse-error (development)', () => { describe('webpack-loader-parse-error (development)', () => {
const { next, isTurbopack, isNextDev, skipped } = nextTestSetup({ const { next, isTurbopack } = nextTestSetup({
files: __dirname, files: __dirname,
skipDeployment: true,
skipStart: true, skipStart: true,
}) })
if (skipped) return
if (!isNextDev) {
it('skipped in production mode', () => {})
return
}
beforeAll(() => next.start()) beforeAll(() => next.start())
...@@ -198,26 +192,29 @@ describe('webpack-loader-parse-error (development)', () => { ...@@ -198,26 +192,29 @@ describe('webpack-loader-parse-error (development)', () => {
}) })
}) })
// @force-gate !dev
describe('webpack-loader-parse-error (production)', () => { describe('webpack-loader-parse-error (production)', () => {
const { next, isNextStart, isTurbopack } = nextTestSetup({ const { next, isTurbopack, isNextDeploy } = nextTestSetup({
files: __dirname, files: __dirname,
skipDeployment: true,
skipStart: true, skipStart: true,
}) })
if (!isNextStart) {
it('skipped in development mode', () => {})
return
}
it('should fail the build with parse errors from loaders', async () => { it('should fail the build with parse errors from loaders', async () => {
await expect(next.start()).rejects.toThrow( await expect(next.start()).rejects.toThrow()
'next build failed with code/signal 1'
)
const output = normalizePaths(stripAnsi(next.cliOutput), next.testDir) const output = normalizePaths(stripAnsi(next.cliOutput), next.testDir)
if (isTurbopack) { if (isNextDeploy) {
// Deployment logs prefix every line with a timestamp and strip
// code-frame indentation, so the exact formatting the snapshots below
// assert cannot survive the round trip. Assert the error titles, which
// are single lines, and leave the formatting to the local build.
expect(output).toContain("Expected '</', got '{'")
if (isTurbopack) {
expect(output).toContain('Parsing CSS source code failed')
}
} else if (isTurbopack) {
const jsError = extractErrorBlock(output, "Expected '</', got '{'") const jsError = extractErrorBlock(output, "Expected '</', got '{'")
expect(jsError).toMatchInlineSnapshot(` expect(jsError).toMatchInlineSnapshot(`
"./app/data.broken.js:3:1 "./app/data.broken.js:3:1
...@@ -299,5 +296,5 @@ describe('webpack-loader-parse-error (production)', () => { ...@@ -299,5 +296,5 @@ describe('webpack-loader-parse-error (production)', () => {
./app/page.js" ./app/page.js"
`) `)
} }
}) }, 240_000)
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment