Skip to content

Commit d5a1153

Browse files
aduh95targos
authored andcommitted
test: use fixtures.fileURL when appropriate
PR-URL: #48990 Backport-PR-URL: #50669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 10e7c3a commit d5a1153

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,20 +3,10 @@
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
const os = require('os');
98

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

2111
assert(url instanceof URL);
2212

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)