Skip to content

Commit

Permalink
test: use fixtures.fileURL when appropriate
Browse files Browse the repository at this point in the history
PR-URL: nodejs#48990
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 pluris committed Aug 7, 2023
1 parent 6c8b82b commit d442e1c
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,19 +3,9 @@
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const path = require('path');
const fs = require('fs');

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 d442e1c

Please sign in to comment.