Skip to content

Commit

Permalink
test: use fixtures.fileURL when appropriate
Browse files Browse the repository at this point in the history
PR-URL: #48990
Backport-PR-URL: #50669
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and targos committed Nov 23, 2023
1 parent 10e7c3a commit d5a1153
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
12 changes: 1 addition & 11 deletions test/parallel/test-fs-whatwg-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-module-create-require.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down

0 comments on commit d5a1153

Please sign in to comment.