File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ import { type FixtureTestContext } from './utils/contexts'
4
4
5
5
// cleanup after each test as a fallback if someone forgot to call it
6
6
afterEach < FixtureTestContext > ( async ( { cleanup } ) => {
7
+ // https://github.com/vercel/next.js/blob/668f8edb0ea47d578c6389a1d6df8fe902dec55c/packages/next/src/server/web/globals.ts#L90-L96
8
+ // Next defines non-configurable property on globalThis which we can't delete and without deletion it cause "Cannot redefine property"
9
+ // errors. So to be able to run tests from multiple fixtures we recreate globalThis without __import_unsupported property.
10
+ const newGlobalThisWithoutImportUnsupported = { }
11
+ const globalProps = Object . getOwnPropertyDescriptors ( globalThis )
12
+ delete globalProps . __import_unsupported
13
+ Object . defineProperties ( newGlobalThisWithoutImportUnsupported , globalProps )
14
+ // @ts -ignore it seems we can assign globalThis despite TS error
15
+ globalThis = newGlobalThisWithoutImportUnsupported
16
+
7
17
if ( 'reset' in fs ) {
8
18
; ( fs as any ) . reset ( )
9
19
}
You can’t perform that action at this time.
0 commit comments