Skip to content

Commit 6c54a81

Browse files
bfirshclaude
andcommitted
Migrate from Mocha/Chai/Sinon to Node built-in test runner
Replace mocha, chai, and sinon with node:test and node:assert/strict (built into Node 22). This removes 3 dev dependencies while keeping identical test coverage (438 pass, 44 skipped). - Convert all fs.readFile callbacks to fs.readFileSync - Replace sinon.spy() with mock.fn() from node:test - Replace this.timeout() with { timeout } options on describe - Replace this.skip() with test context t.skip() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1f50f96 commit 6c54a81

File tree

8 files changed

+766
-1952
lines changed

8 files changed

+766
-1952
lines changed

package-lock.json

Lines changed: 0 additions & 880 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@
1414
"scripts": {
1515
"build": "webpack",
1616
"typecheck": "tsc --noEmit",
17-
"test": "npm run typecheck && prettier --check src/**/*.js && mocha ./test/*.spec.js",
18-
"test:watch": "mocha -w ./test/*.spec.js",
17+
"test": "npm run typecheck && prettier --check src/**/*.js && node --test ./test/*.spec.js",
18+
"test:watch": "node --test --watch ./test/*.spec.js",
1919
"prepublish": "npm run build",
2020
"format": "prettier --write src/**/*.js"
2121
},
2222
"devDependencies": {
2323
"@types/node": "^25.0.2",
24-
"chai": "^6.2.2",
2524
"eslint": "^9.15.0",
2625
"eslint-config-prettier": "^10.1.8",
2726
"eslint-webpack-plugin": "^5.0.2",
28-
"mocha": "^11.7.1",
2927
"prettier": "^3.6.2",
30-
"sinon": "^21.0.0",
3128
"terser-webpack-plugin": "^5.3.10",
3229
"typescript": "^5.8.3",
3330
"webpack": "^5.100.2",

test/accuracycoin.spec.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { assert } from "chai";
1+
import assert from "node:assert/strict";
2+
import { describe, it, before, after } from "node:test";
23
import fs from "fs";
34
import NES from "../src/nes.js";
45
import Controller from "../src/controller.js";
@@ -419,17 +420,12 @@ function formatResult(value) {
419420
);
420421
}
421422

422-
describe("AccuracyCoin", function () {
423-
this.timeout(600000); // 10 minutes — running 134 tests takes a while
424-
423+
describe("AccuracyCoin", { timeout: 600000 }, function () {
425424
let run;
426425

427-
before(function (done) {
428-
fs.readFile("roms/AccuracyCoin/AccuracyCoin.nes", function (err, data) {
429-
if (err) return done(err);
430-
run = runAccuracyCoin(data.toString("binary"));
431-
done();
432-
});
426+
before(function () {
427+
let data = fs.readFileSync("roms/AccuracyCoin/AccuracyCoin.nes");
428+
run = runAccuracyCoin(data.toString("binary"));
433429
});
434430

435431
it("should not crash before completing all tests", function () {
@@ -479,10 +475,11 @@ describe("AccuracyCoin", function () {
479475
it.skip(test.name + " — " + knownFailure, function () {});
480476
return;
481477
}
482-
it(test.name, function () {
478+
it(test.name, function (t) {
483479
let result = run.results[test.addr];
484480
if (result === 0x00) {
485-
this.skip(); // not run (likely due to earlier crash)
481+
t.skip(); // not run (likely due to earlier crash)
482+
return;
486483
}
487484
if (!isPass(result)) {
488485
assert.fail(

0 commit comments

Comments
 (0)