Skip to content

Commit a061781

Browse files
authored
test: use fixtures.fileURL when appropriate
PR-URL: #48990 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1353681 commit a061781

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

test/parallel/test-fs-whatwg-url.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@
33
const common = require('../common');
44
const fixtures = require('../common/fixtures');
55
const assert = require('assert');
6-
const path = require('path');
76
const fs = require('fs');
87

9-
function pathToFileURL(p) {
10-
if (!path.isAbsolute(p))
11-
throw new Error('Path must be absolute');
12-
if (common.isWindows && p.startsWith('\\\\'))
13-
p = p.slice(2);
14-
return new URL(`file://${p}`);
15-
}
16-
17-
const p = path.resolve(fixtures.fixturesDir, 'a.js');
18-
const url = pathToFileURL(p);
8+
const url = fixtures.fileURL('a.js');
199

2010
assert(url instanceof URL);
2111

test/parallel/test-module-create-require.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict';
22

33
require('../common');
4+
const fixtures = require('../common/fixtures');
45
const assert = require('assert');
5-
const path = require('path');
66

77
const { createRequire } = require('module');
88

9-
const p = path.resolve(__dirname, '..', 'fixtures', 'fake.js');
10-
const u = new URL(`file://${p}`);
9+
const u = fixtures.fileURL('fake.js');
1110

1211
const reqToo = createRequire(u);
1312
assert.deepStrictEqual(reqToo('./experimental'), { ofLife: 42 });

0 commit comments

Comments
 (0)