diff --git a/test/parallel/test-fs-whatwg-url.js b/test/parallel/test-fs-whatwg-url.js index 829cfa92fafebd..5e9ea98a5820ed 100644 --- a/test/parallel/test-fs-whatwg-url.js +++ b/test/parallel/test-fs-whatwg-url.js @@ -3,20 +3,10 @@ const common = require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const os = require('os'); -function pathToFileURL(p) { - if (!path.isAbsolute(p)) - throw new Error('Path must be absolute'); - if (common.isWindows && p.startsWith('\\\\')) - p = p.slice(2); - return new URL(`file://${p}`); -} - -const p = path.resolve(fixtures.fixturesDir, 'a.js'); -const url = pathToFileURL(p); +const url = fixtures.fileURL('a.js'); assert(url instanceof URL); diff --git a/test/parallel/test-module-create-require.js b/test/parallel/test-module-create-require.js index e0e34e9f127bd3..30ebf96652390d 100644 --- a/test/parallel/test-module-create-require.js +++ b/test/parallel/test-module-create-require.js @@ -1,13 +1,12 @@ 'use strict'; require('../common'); +const fixtures = require('../common/fixtures'); const assert = require('assert'); -const path = require('path'); const { createRequire } = require('module'); -const p = path.resolve(__dirname, '..', 'fixtures', 'fake.js'); -const u = new URL(`file://${p}`); +const u = fixtures.fileURL('fake.js'); const reqToo = createRequire(u); assert.deepStrictEqual(reqToo('./experimental'), { ofLife: 42 });