File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 55
66import type { Config } from 'jest' ;
77import { pathsToModuleNameMapper } from "ts-jest" ;
8- import { compilerOptions } from './tsconfig.json' ;
8+ import { createRequire } from 'module' ;
9+ const { compilerOptions } = createRequire ( import . meta. url ) ( './tsconfig.json' ) ;
10+
11+ const compilerPaths = compilerOptions . paths as Record < string , string [ ] > ;
12+ const cleanedPaths : Record < string , string [ ] > = { } ;
13+ Object . keys ( compilerPaths ) . forEach ( ( key ) => {
14+ const paths = compilerPaths [ key ] ;
15+ cleanedPaths [ key ] = paths . map ( p => p . replace ( './' , '' ) ) ;
16+ } ) ;
917
1018const config : Config = {
1119 // All imported modules in your tests should be mocked automatically
@@ -98,7 +106,7 @@ const config: Config = {
98106 // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
99107 moduleNameMapper : {
100108 'lexical/shared/invariant' : 'resources/js/wysiwyg/lexical/core/shared/__mocks__/invariant' ,
101- ...pathsToModuleNameMapper ( compilerOptions . paths ) ,
109+ ...pathsToModuleNameMapper ( cleanedPaths ) ,
102110 } ,
103111
104112 // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Original file line number Diff line number Diff line change 66 "module" : " esnext" ,
77 "moduleResolution" : " bundler" ,
88 "rootDir" : " ./resources/js/" ,
9- "types" : [" jest" ],
9+ "types" : [" jest" , " node " ],
1010 "paths" : {
1111 "@icons/*" : [" ./resources/icons/*" ],
1212 "lexical" : [" ./resources/js/wysiwyg/lexical/core/index.ts" ],
You can’t perform that action at this time.
0 commit comments