rsnext/test/e2e/app-dir/taint/process-taint.test.ts
Sebastian Markbåge c41debd23a
Expose Experimental Taint APIs (#56507)
Exposes the new experimental Taint APIs using the `taint` flag which
enables experimental React.

As an example for how we can use it, I use it to taint `process.env`
with a better error message. I'm not sure where this should live since
it's a global init but it needs access to the global config. It's
unnecessary to retaint it for every render but not sure if there's a
better place for it.

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-19 19:02:37 -07:00

25 lines
879 B
TypeScript

import { createNextDescribe } from 'e2e-utils'
const GENERIC_RSC_ERROR =
'An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.'
export function runTest({ next, isNextDev }) {
it('should error when passing process env to client component', async () => {
const browser = await next.browser('/')
expect(await browser.waitForElementByCss('#error-component').text()).toBe(
isNextDev
? 'Do not pass process.env to client components since it will leak sensitive data'
: GENERIC_RSC_ERROR
)
})
}
createNextDescribe(
'app dir - taint',
{
files: __dirname,
},
({ next, isNextDev }) => {
runTest({ next, isNextDev })
}
)