File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { fileURLToPath } from 'url' ;
1
2
import { expect } from 'chai'
2
3
import fs from 'fs'
3
4
import sinon from "sinon" ;
4
5
import { availableProviders , match } from '../../src/provider.js' ;
5
6
import esmock from 'esmock' ;
6
7
import { fail } from 'assert' ;
8
+ import { dirname , resolve } from 'path' ;
7
9
8
10
let clock
9
11
12
+ const __filename = fileURLToPath ( import . meta. url ) ;
13
+ const __dirname = dirname ( __filename ) ;
10
14
11
15
async function mockProvider ( providerName , listingOutput ) {
12
16
13
17
const mockExecSync = ( cmd ) => {
14
- if ( cmd . includes ( '--version' ) ) { return '' ; }
18
+ if ( cmd . includes ( '--version' ) ) { return '' ; }
15
19
return listingOutput ;
16
- }
20
+ } ;
21
+
22
+ const baseProviderPath = resolve ( __dirname , '../../src/providers/Base_javascript.js' ) ;
23
+ const targetProviderPath = resolve ( __dirname , `../../src/providers/Javascript_${ providerName } .js` ) ;
17
24
18
- return esmock ( `../../src/providers/Javascript_ ${ providerName } .js` , {
19
- '../../src/providers/Base_javascript.js' : await esmock ( '../../src/providers/Base_javascript.js' , {
25
+ return esmock ( targetProviderPath , {
26
+ [ baseProviderPath ] : await esmock ( baseProviderPath , {
20
27
'node:child_process' : {
21
28
execSync : mockExecSync
22
29
}
You can’t perform that action at this time.
0 commit comments