File tree 1 file changed +19
-1
lines changed
packages/jest/src/plugins 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -109,18 +109,36 @@ export const createNodes: CreateNodes<JestPluginOptions> = [
109
109
} ,
110
110
] ;
111
111
112
+ const jestValidatePath = dirname (
113
+ require . resolve ( 'jest-validate/package.json' , {
114
+ paths : [ dirname ( require . resolve ( 'jest-config' ) ) ] ,
115
+ } )
116
+ ) ;
117
+
112
118
async function buildJestTargets (
113
119
configFilePath : string ,
114
120
projectRoot : string ,
115
121
options : JestPluginOptions ,
116
122
context : CreateNodesContext
117
123
) : Promise < Pick < ProjectConfiguration , 'targets' | 'metadata' > > {
124
+ const absConfigFilePath = resolve ( context . workspaceRoot , configFilePath ) ;
125
+
126
+ if ( require . cache [ absConfigFilePath ] ) {
127
+ for ( const k of Object . keys ( require . cache ) ) {
128
+ // Only delete the cache outside of jest-validate
129
+ // jest-validate has a Symbol which is important for jest config validation which breaks if the require cache is broken
130
+ if ( relative ( jestValidatePath , k ) . startsWith ( '../' ) ) {
131
+ delete require . cache [ k ] ;
132
+ }
133
+ }
134
+ }
135
+
118
136
const config = await readConfig (
119
137
{
120
138
_ : [ ] ,
121
139
$0 : undefined ,
122
140
} ,
123
- resolve ( context . workspaceRoot , configFilePath )
141
+ absConfigFilePath
124
142
) ;
125
143
126
144
const namedInputs = getNamedInputs ( projectRoot , context ) ;
You can’t perform that action at this time.
0 commit comments