mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
1. Align the code highlight marker color with the issue severity 2. Make the issue title colored 3. Prefix issues with `Warning` or `Error` <img width="1383" height="862" alt="Bildschirmfoto 2026-06-16 um 18 59 03" src="https://github.com/user-attachments/assets/f98c606d-4ea8-40c2-836d-e395f1df904c" /> <img width="1039" height="450" alt="Bildschirmfoto 2026-06-16 um 19 03 39" src="https://github.com/user-attachments/assets/2747f914-0587-4178-a87d-344f24715c96" /> <details> <summary>Old</summary> <img width="1267" height="745" alt="Bildschirmfoto 2026-06-16 um 17 04 35" src="https://github.com/user-attachments/assets/837739ff-82f7-4ea2-8767-ca7d866a8570" /> </details>
68 lines
2.7 KiB
TypeScript
68 lines
2.7 KiB
TypeScript
/* eslint-env jest */
|
|
|
|
import { isNextStart, nextTestSetup } from 'e2e-utils'
|
|
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
|
|
|
|
describe('Invalid Global CSS', () => {
|
|
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({
|
|
files: __dirname,
|
|
skipStart: isNextStart,
|
|
skipDeployment: true,
|
|
dependencies: { sass: '1.54.0' },
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
if (isNextStart) {
|
|
it('should fail to build', async () => {
|
|
const { exitCode, cliOutput } = await next.build()
|
|
expect(exitCode).not.toBe(0)
|
|
if (!isTurbopack) {
|
|
expect(cliOutput).toContain('Failed to compile')
|
|
}
|
|
expect(cliOutput).toContain('styles/global.scss')
|
|
expect(cliOutput).toMatch(
|
|
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
|
|
)
|
|
// Skip: Rspack loaders cannot access module issuer info for location details
|
|
if (!process.env.NEXT_RSPACK) {
|
|
expect(cliOutput).toMatch(/Location:.*pages[\\/]index\.js/)
|
|
}
|
|
})
|
|
} else {
|
|
it('should show a build error', async () => {
|
|
const browser = await next.browser('/')
|
|
|
|
await waitForRedbox(browser)
|
|
const errorSource = await getRedboxSource(browser)
|
|
|
|
if (isTurbopack) {
|
|
expect(errorSource).toMatchInlineSnapshot(`
|
|
"./pages/index.js
|
|
Error: Global CSS cannot be imported from files other than your Custom <App>.
|
|
Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to pages/_app.js. Or convert the import to Component-Level CSS (CSS Modules).
|
|
Location: pages/index.js
|
|
Import path: ../styles/global.scss
|
|
|
|
https://nextjs.org/docs/messages/css-global"
|
|
`)
|
|
} else if (isRspack) {
|
|
expect(errorSource).toMatchInlineSnapshot(`
|
|
"./styles/global.scss
|
|
│ Global CSS cannot be imported from files other than your Custom <App>. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to pages/_app.js. Or convert the import to Component-Level CSS (CSS Modules).
|
|
│ Read more: https://nextjs.org/docs/messages/css-global"
|
|
`)
|
|
} else {
|
|
expect(errorSource).toMatchInlineSnapshot(`
|
|
"./styles/global.scss
|
|
Global CSS cannot be imported from files other than your Custom <App>. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to pages/_app.js. Or convert the import to Component-Level CSS (CSS Modules).
|
|
Read more: https://nextjs.org/docs/messages/css-global
|
|
Location: pages/index.js"
|
|
`)
|
|
}
|
|
})
|
|
}
|
|
})
|