Skip to content

Commit 2a8f687

Browse files
committed
Restructure for node:test compat
also, fix call to parseAll method
1 parent 18e4607 commit 2a8f687

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
"reffy": "18.6.3",
3939
"rimraf": "6.0.1",
4040
"strudy": "^3.1.1",
41-
"webidl2": "24.4.1"
41+
"webidl2": "^24.4.1"
4242
},
4343
"scripts": {
4444
"create-patch": "node tools/create-patch.js",
4545
"curate": "node tools/prepare-curated.js ed curated && node tools/prepare-packages.js curated packages",
46-
"test": "mocha --recursive",
46+
"test": "node --test",
4747
"test-css": "mocha --recursive test/css",
4848
"test-elements": "mocha --recursive test/elements",
4949
"test-idl": "mocha --recursive test/idl"

test/idl/validate.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* the package view, e.g. due to missing base interfaces.
1010
*/
1111

12-
import { describe, it, before } from 'node:test';
12+
import { describe, it } from 'node:test';
1313
import { strict as assert } from 'node:assert';
1414
import path from 'node:path';
1515
import { fileURLToPath } from 'node:url';
@@ -21,6 +21,7 @@ const curatedView = {
2121
name: 'curated',
2222
folder: path.join(scriptPath, '..', '..', 'curated', 'idl')
2323
};
24+
2425
const packageView = {
2526
name: '@webref/idl package',
2627
folder: path.join(scriptPath, '..', '..', 'packages', 'idl')
@@ -41,40 +42,39 @@ function validate(ast) {
4142
assert.fail(message);
4243
}
4344

44-
describe(`The ${curatedView.name} view of Web IDL extracts`, function () {
45+
describe(`The ${curatedView.name} view of Web IDL extracts`, async function () {
4546
let all;
46-
before(async () => {
47-
all = await idl.parseAll(curatedView.folder);
48-
});
49-
50-
it(`The ${curatedView.name} view of Web IDL extracts`, function () {
51-
for (const [spec, ast] of Object.entries(all)) {
52-
it(`contains valid Web IDL for ${spec}`, function () {
53-
validate(ast);
54-
});
55-
}
56-
});
47+
try {
48+
all = await idl.parseAll({folder: curatedView.folder});
49+
} catch (err) {
50+
it('contains data that can be parsed with webidl2.js', () => {throw err ;});
51+
};
5752

58-
it(`The combined Web IDL in the ${curatedView.name} view`, function () {
53+
for (const [spec, ast] of Object.entries(all)) {
54+
it(`contains valid Web IDL for ${spec}`, function () {
55+
validate(ast);
56+
});
57+
}
58+
describe(`The combined Web IDL in the ${curatedView.name} view`, function () {
5959
it('is valid Web IDL', function () {
6060
validate(Object.values(all).flat());
6161
});
6262
});
63-
6463
});
6564

66-
6765
describe(`The ${packageView.name} view of Web IDL extracts`, async () => {
68-
before(async () => {
69-
const all = await idl.parseAll(packageView.folder);
66+
let all;
67+
try {
68+
all = await idl.parseAll({folder: packageView.folder});
69+
} catch (err) {
70+
it('contains data that can be parsed with webidl2.js', () => {throw err;});
71+
}
7072

71-
describe(`The combined Web IDL in the ${packageView.name} view`, function () {
72-
it('is valid Web IDL', function () {
73-
validate(Object.values(all).flat());
74-
});
73+
describe(`The combined Web IDL in the ${packageView.name} view`, function () {
74+
it('is valid Web IDL', function () {
75+
validate(Object.values(all).flat());
7576
});
7677
});
77-
78-
it('contains data that can be parsed with webidl2.js', () => {});
78+
7979
});
8080

0 commit comments

Comments
 (0)