Skip to content

Commit

Permalink
fix: use file urls for chokidar import
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j committed Mar 23, 2024
1 parent 9a93273 commit 5fc2ac2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import fs from 'node:fs';
import sysPath from 'node:path';
import {fileURLToPath} from 'node:url';
import {fileURLToPath, pathToFileURL} from 'node:url';
import {promisify} from 'node:util';
import childProcess from 'node:child_process';
import chai from 'chai';
Expand Down Expand Up @@ -543,14 +543,13 @@ const runTests = (baseopts) => {
watcher.on(EV.UNLINK, unlinkSpy).on(EV.ADD_DIR, addSpy);
await waitForWatcher(watcher);

await delay();
await delay(300);
await fs_unlink(testPath);
await delay();
await delay(300);
await fs_mkdir(testPath, PERM_ARR);

await waitFor([unlinkSpy]);
await waitFor([addSpy, unlinkSpy]);
unlinkSpy.should.have.been.calledWith(testPath);
await waitFor([addSpy]);
addSpy.should.have.been.calledWith(testPath);
});
});
Expand Down Expand Up @@ -2026,7 +2025,9 @@ const runTests = (baseopts) => {
});
it('should not prevent the process from exiting', async () => {
const scriptFile = getFixturePath('script.js');
const chokidarPath = upath.join(__dirname, 'lib/index.js').replace(/\\/g, '\\\\');
const chokidarPath = pathToFileURL(sysPath.join(__dirname, 'lib/index.js'))
.href
.replace(/\\/g, '\\\\');
const scriptContent = `
(async () => {
const chokidar = await import("${chokidarPath}");
Expand Down

0 comments on commit 5fc2ac2

Please sign in to comment.