Skip to content

Commit b7683ed

Browse files
committed
Remove chai dependency
Its newest version is ESM-only, and Node.js's built-in assert is basically good enough.
1 parent b2b6956 commit b7683ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1029
-1236
lines changed

.eslintignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
node_modules
22

3-
benchmark/browser-bundle.js
4-
benchmark/browser-runner.html
53
benchmark/selectors/sizzle-speed
6-
test/worker-bundle.js
74

85
lib/jsdom/browser/default-stylesheet.js
96
lib/jsdom/level3/xpath.js
107

118
lib/jsdom/living/generated/**
129

13-
test/*.js
14-
!test/chai-helpers.js
15-
!test/karma*
16-
!test/util.js
17-
1810
test/api/fixtures
1911
test/jquery-fixtures
2012
test/to-port-to-wpts/files

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
gmon.out
66
v8.log
77
node_modules
8-
test/worker-bundle.js
98
test/web-platform-tests/tuwpt-manifest.json
109
npm-debug.log*
11-
benchmark/browser-bundle.js
1210

1311
lib/jsdom/living/generated/**/*.js
1412
lib/jsdom/browser/js-globals.json

lib/jsdom/level3/xpath.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,19 @@ module.exports = core => {
123123
if ('"' === first && '"' === last ||
124124
"'" === first && "'" === last) {
125125
this.pop();
126-
return tok.substr(1, tok.length - 2);
126+
return tok.substr(1, tok.length - 2) ?? null;
127127
}
128+
return null;
128129
},
129130
trypopnumber: function() {
130131
var tok = this.peek();
131-
if (this.isNumberRe.test(tok)) return parseFloat(this.pop());
132+
if (this.isNumberRe.test(tok)) return parseFloat(this.pop()) ?? null;
132133
else return null;
133134
},
134135
trypopvarref: function() {
135136
var tok = this.peek();
136137
if (null == tok) return null;
137-
if ('$' === tok.charAt(0)) return this.pop().substr(1);
138+
if ('$' === tok.charAt(0)) return this.pop().substr(1) ?? null;
138139
else return null;
139140
},
140141
position: function() {

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"devDependencies": {
5454
"@domenic/eslint-config": "^3.0.0",
5555
"benchmark": "^2.1.4",
56-
"chai": "^4.3.10",
5756
"eslint": "^8.56.0",
5857
"eslint-plugin-html": "^7.1.0",
5958
"eslint-plugin-jsdom-internal": "file:./scripts/eslint-plugin",

test/api/basics.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
const { assert } = require("chai");
2+
const assert = require("node:assert/strict");
33
const { describe, it } = require("mocha-sugar-free");
44

55
const { JSDOM } = require("../..");
@@ -8,22 +8,22 @@ describe("JSDOM instances: basics", () => {
88
it("should have a window and a document", () => {
99
const dom = new JSDOM();
1010

11-
assert.isOk(dom.window);
12-
assert.isOk(dom.window.document);
11+
assert.ok(dom.window);
12+
assert.ok(dom.window.document);
1313
});
1414

1515
it("should have a document with documentElement <html> when no arguments are passed", () => {
1616
const { document } = (new JSDOM()).window;
1717

18-
assert.strictEqual(document.documentElement.localName, "html");
18+
assert.equal(document.documentElement.localName, "html");
1919
});
2020
});
2121

2222
describe("JSDOM() constructor first argument", () => {
2323
it("should populate the resulting document with the given HTML", () => {
2424
const { document } = (new JSDOM(`<a id="test" href="#test">`)).window;
2525

26-
assert.strictEqual(document.getElementById("test").getAttribute("href"), "#test");
26+
assert.equal(document.getElementById("test").getAttribute("href"), "#test");
2727
});
2828

2929
it("should give the same document innerHTML for empty and whitespace and omitted strings", () => {
@@ -32,24 +32,24 @@ describe("JSDOM() constructor first argument", () => {
3232
const document3 = (new JSDOM(``)).window.document;
3333
const document4 = (new JSDOM(` `)).window.document;
3434

35-
assert.strictEqual(document1.innerHTML, document2.innerHTML);
36-
assert.strictEqual(document2.innerHTML, document3.innerHTML);
37-
assert.strictEqual(document3.innerHTML, document4.innerHTML);
35+
assert.equal(document1.innerHTML, document2.innerHTML);
36+
assert.equal(document2.innerHTML, document3.innerHTML);
37+
assert.equal(document3.innerHTML, document4.innerHTML);
3838
});
3939

4040
it("should coerce null to a string", () => {
4141
const document1 = (new JSDOM(null)).window.document;
4242
const document2 = (new JSDOM("null")).window.document;
4343

44-
assert.strictEqual(document1.innerHTML, document2.innerHTML);
44+
assert.equal(document1.innerHTML, document2.innerHTML);
4545
});
4646

4747
describe("error reporting", () => {
4848
it("should include the URL when reporting an XML parse error", () => {
4949
assert.throws(() => new JSDOM("<doc><!-- ... ---></doc>", {
5050
url: "https://example.com/",
5151
contentType: "text/xml"
52-
}), "https://example.com/:1:17:%20malformed%20comment.");
52+
}), Error, "https://example.com/:1:17:%20malformed%20comment.");
5353
});
5454
});
5555
});

test/api/cookies.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
const { assert } = require("chai");
2+
const assert = require("node:assert/strict");
33
const { describe, it, before, after } = require("mocha-sugar-free");
44
const { createServer, createHTTPSServer } = require("../util.js");
55

@@ -133,7 +133,7 @@ describe("Cookie processing", () => {
133133
const futureDate = new Date(timeNow + 24 * 60 * 60 * 1000);
134134
window.document.cookie = "Test=FooBar; Expires=" + futureDate.toString();
135135

136-
assert.strictEqual(window.document.cookie, "Test=FooBar");
136+
assert.equal(window.document.cookie, "Test=FooBar");
137137
});
138138
});
139139

0 commit comments

Comments
 (0)