Skip to content

chore: Replace mocha/expect/sinon/nyc with node:test harness - #90

Merged
phated merged 30 commits into
gulpjs:mainfrom
FotoVerite:main
Nov 7, 2026
Merged

phated merged 30 commits into
gulpjs:mainfrom
FotoVerite:main

Conversation

@FotoVerite

Copy link
Copy Markdown
Contributor

Closes #89

This is not complete yet, there are some tests that seem to do nothing. I have kept them commented out so they are easily looked at

t.plan might not work the same as assertions so the first debounce test might need to be written

and #46 is happening again?

@FotoVerite FotoVerite self-assigned this Oct 23, 2026
@FotoVerite
FotoVerite requested a review from phated October 23, 2026 16:06
@FotoVerite

Copy link
Copy Markdown
Contributor Author

So I've been able to fix most tests, I'm using a promise to await before checking runs which seems like a sane choice to deal with the assert swallowing I found wish it was a bit more elegant but it isn't cludge.

I removed t.plan(1) from the debounce test because I can't figure out the purpose of it originally and it always should have been 2 from my reading of the mocha the other test is showing a regression

// #46
it("ignoring globs also works with cwd option", function (t, done) {
watcher = watch(["fixtures/**", "!fixtures/*.js"], { cwd: "test" });

watcher.once("change", function (filepath) {
  // It should never reach here
  assert.ok(!filepath);
  done();
});

// We default `ignoreInitial` to true, so always wait for `on('ready')`
watcher.on("ready", changeFile);

setTimeout(done, 1500);

});

i'm unsure why this passed in the mocha and looks like it's related to chokidar and probably needs actual code changes and or an update to chokidar which is on 6.

@phated phated left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes still needed and I will think about the promise usage.

Comment thread test/lib/debounce.test.js Resolved
Comment thread test/lib/debounce.test.js Resolved
Comment thread .gitignore Resolved
Comment thread test/lib/normalize-args.test.js Resolved
Comment thread test/index.js Resolved
Comment thread test/index.js Resolved
Comment thread test/index.js Resolved
FotoVerite and others added 3 commits October 25, 2026 14:17
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
@phated phated added this to v6 Oct 26, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in v6 Oct 26, 2026
@FotoVerite

FotoVerite commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

i'm unsure why this passed in the mocha and looks like it's related to chokidar and probably needs actual code changes and or an update to chokidar which is on 6.

So the bug can be fixed if we resolve the cwd option before passing to chokidor.

path.resolve(opts.cwd)

What are our plans with chokidor since it changed how it worked in version 4 and beyond? Can confirm it breaks the entire library when I tried upgrading it to see if that fixed the issue.

Interesting I thought resolve was doing the same as normalize-path as in the original patch from v5 but that's a brain fritz. Lucky break. Has to be something with chokidor and how it's handling changing the directory. Probably why resolve is fixing it due to it making it absolute.

Comment thread test/index.js Resolved
Comment thread test/lib/debounce.test.js Resolved
Comment thread test/lib/debounce.test.js Resolved
@phated

phated commented Nov 6, 2026

Copy link
Copy Markdown
Member

Your debugging here put me on the right path to discover that chokidar v3.6.0 requires cwd to be an absolute path, otherwise their entire path resolving logic fails. Since we pass cwd directly through to chokidar, I think we don't want to do any normalization on it and instead just fix the test to show that cwd must be absolute (such as __dirname) and comment that the original reproduction in the linked issue was flawed.

@phated phated changed the title chore: Replace mocha/expect/nyc with node:test harness chore: Replace mocha/expect/sinon/nyc with node:test harness Nov 7, 2026

@phated phated left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good-to-go! It found a bunch of bugs with Chokidar 3 and globs (particularly on Windows) which is really good to highlight in the test suite for when we rewrite this library. Thanks!

@phated
phated merged commit 74dcfc4 into gulpjs:main Nov 7, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in v6 Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Update test harness

2 participants