Skip to content

Commit 36305a7

Browse files
committed
feat: use resolve for relative paths
Signed-off-by: Ruben Romero Montes <[email protected]>
1 parent 7b83239 commit 36305a7

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

test/providers/javascript.test.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1+
import { fileURLToPath } from 'url';
12
import { expect } from 'chai'
23
import fs from 'fs'
34
import sinon from "sinon";
45
import { availableProviders, match } from '../../src/provider.js';
56
import esmock from 'esmock';
67
import { fail } from 'assert';
8+
import { dirname, resolve } from 'path';
79

810
let clock
911

12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = dirname(__filename);
1014

1115
async function mockProvider(providerName, listingOutput) {
1216

1317
const mockExecSync = (cmd) => {
14-
if (cmd.includes('--version')) { return ''; }
18+
if (cmd.includes('--version')) {return '';}
1519
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`);
1724

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, {
2027
'node:child_process': {
2128
execSync: mockExecSync
2229
}

0 commit comments

Comments
 (0)