File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ function createConfigSet({
3333} = { } ) {
3434 const cs = new ConfigSet ( fakers . jestConfig ( jestConfig , tsJestConfig ) , parentConfig )
3535 if ( resolve ) {
36- jest . spyOn ( cs , 'resolvePath' ) . mockImplementation ( resolve )
36+ cs . resolvePath = resolve
3737 }
3838 return cs
3939}
@@ -240,3 +240,13 @@ describe('typescript', () => {
240240 } )
241241 } )
242242} )
243+
244+ describe ( 'resolvePath' , ( ) => {
245+ it ( 'should resolve paths' , ( ) => {
246+ const cs = createConfigSet ( { jestConfig : { rootDir : '/root' , cwd : '/cwd' } as any , resolve : null } )
247+ expect ( normalizeSlashes ( cs . resolvePath ( 'bar.js' , { throwIfMissing : false } ) ) ) . toBe ( '/cwd/bar.js' )
248+ expect ( normalizeSlashes ( cs . resolvePath ( './bar.js' , { throwIfMissing : false } ) ) ) . toBe ( '/cwd/bar.js' )
249+ expect ( normalizeSlashes ( cs . resolvePath ( '<rootDir>bar.js' , { throwIfMissing : false } ) ) ) . toBe ( '/root/bar.js' )
250+ expect ( normalizeSlashes ( cs . resolvePath ( '<rootDir>/bar.js' , { throwIfMissing : false } ) ) ) . toBe ( '/root/bar.js' )
251+ } )
252+ } )
Original file line number Diff line number Diff line change @@ -512,7 +512,7 @@ export class ConfigSet {
512512 let path : string = inputPath
513513 let nodeResolved = false
514514 if ( path . startsWith ( '<rootDir>' ) ) {
515- path = resolve ( this . rootDir , path . substr ( 9 ) )
515+ path = resolve ( join ( this . rootDir , path . substr ( 9 ) ) )
516516 } else if ( ! isAbsolute ( path ) ) {
517517 if ( ! path . startsWith ( '.' ) && nodeResolve ) {
518518 try {
You can’t perform that action at this time.
0 commit comments