Files
next.js/test/development/report-system-env-var-inlining/report-system-env-var-inlining.test.ts
Niklas MischkulnigandGitHub 9b8a7a1055 Turbopack: improve issue printing colors (#94858)
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>
2026-06-16 21:29:37 +02:00

36 lines
1.2 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
// Only implemented in Turbopack
import { getRedboxSource, waitForRedbox } from 'next-test-utils'
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
'report-system-env-var-inlining',
() => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should report when inlining system env vars', async () => {
const browser = await next.browser('/')
await waitForRedbox(browser)
const error = await getRedboxSource(browser)
expect(error).toMatchInlineSnapshot(`
"./app/foo.tsx (2:14)
Error: TP1202 The commit hash is being inlined.
1 | export function Foo() {
> 2 | return <p>{process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA}</p>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | }
4 |
This variable changes frequently, causing slower deploy times and worse browser client-side caching. Consider using \`process.env.NEXT_DEPLOYMENT_ID\` to identify a deployment. Alternatively, use \`process.env.VERCEL_GIT_COMMIT_SHA\` in server side code and for browser code, remove it.
Import trace:
Server Component:
./app/foo.tsx
./app/page.tsx"
`)
})
}
)