diff --git a/package.json b/package.json index 80bb6df57a0d..db81f0674cc1 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "scripts": { "create-patch": "node tools/create-patch.js", "curate": "node tools/prepare-curated.js ed curated && node tools/prepare-packages.js curated packages", - "test": "mocha --recursive", - "test-css": "mocha --recursive test/css", - "test-elements": "mocha --recursive test/elements", - "test-idl": "mocha --recursive test/idl" + "test": "node --test", + "test-css": "node --test \"test/css/*.js\"", + "test-elements": "node --test \"test/elements/*.js\"", + "test-idl": "node --test \"test/idl/*.js\"" } } diff --git a/test/cddl/all.js b/test/cddl/all.js index dfffb06974d9..98e8769e36a4 100644 --- a/test/cddl/all.js +++ b/test/cddl/all.js @@ -4,6 +4,7 @@ * The tests run against the curated view of the extracts. */ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -19,9 +20,8 @@ function writeAnomalies(report) { report.map(anomaly => anomaly.content).join('\n'); } -describe('The curated view of CDDL extracts', function () { - // First run may download micropip and cddlparser packages from the net - this.timeout(30000); +describe('The curated view of CDDL extracts', {timeout: 30000}, function () { + // Long timeout as first run may download micropip and cddlparser packages it('passes Strudy\'s scrutiny', async function () { const crawlFile = path.join(curatedFolder, 'index.json'); diff --git a/test/css/all.js b/test/css/all.js index c7671adc0753..c082949a22ec 100644 --- a/test/css/all.js +++ b/test/css/all.js @@ -7,6 +7,7 @@ * data because that view is a strict subset of the curated view. */ +import { describe, it, before } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; diff --git a/test/css/package.js b/test/css/package.js index ff286bb012d2..0fb63b18f0bc 100644 --- a/test/css/package.js +++ b/test/css/package.js @@ -1,3 +1,4 @@ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import cssPackage from '../../packages/css/package.json' with { type: 'json' }; diff --git a/test/elements/all.js b/test/elements/all.js index 7b0b4482abba..da93242537fa 100644 --- a/test/elements/all.js +++ b/test/elements/all.js @@ -7,6 +7,7 @@ * the data because that view is a strict subset of the curated view. */ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -17,7 +18,6 @@ const curatedFolder = path.join(scriptPath, '..', '..', 'curated', 'elements'); describe('The curated view of elements extracts', function () { it('contains valid JSON and expected properties', async function () { - this.slow(5000); const all = await elements.listAll({ folder: curatedFolder }); assert(Object.keys(all).length > 0); diff --git a/test/elements/consistency.js b/test/elements/consistency.js index ed66fea43a33..576a8724c38f 100644 --- a/test/elements/consistency.js +++ b/test/elements/consistency.js @@ -6,6 +6,7 @@ * view because of some missing IDL definition in that view. */ +import { describe, it, before } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; diff --git a/test/events/all.js b/test/events/all.js index c04107462b54..53bb97d3955d 100644 --- a/test/events/all.js +++ b/test/events/all.js @@ -7,6 +7,7 @@ * the data because that view is a strict subset of the curated view. */ +import { describe, it, before } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -146,4 +147,4 @@ describe('The curated view of events extracts', () => { // Dummy test to make sure that "before" function runs and has a place // to report runtime errors it('contains events', () => {}); -}); \ No newline at end of file +}); diff --git a/test/idl/all.js b/test/idl/all.js index c6f23947b381..52f0ba59e6c4 100644 --- a/test/idl/all.js +++ b/test/idl/all.js @@ -7,6 +7,7 @@ * data because that view is a strict subset of the curated view. */ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -16,7 +17,6 @@ const scriptPath = path.dirname(fileURLToPath(import.meta.url)); const curatedFolder = path.join(scriptPath, '..', '..', 'curated', 'idl'); describe('The curated view of Web IDL extracts', function () { - this.slow(5000); it('contains valid JSON and expected properties', async function () { const files = await idl.listAll({ folder: curatedFolder }); diff --git a/test/idl/consistency.js b/test/idl/consistency.js index bf9f4c0a2463..68a702d46862 100644 --- a/test/idl/consistency.js +++ b/test/idl/consistency.js @@ -10,6 +10,7 @@ * view because of some missing IDL definition in that view. */ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -59,4 +60,4 @@ views.forEach(({ name, folder }) => { assert.equal(results.length, 0, writeAnomalies(results)); }); }); -}); \ No newline at end of file +}); diff --git a/test/idl/package.js b/test/idl/package.js index 40794682f9a6..73c666ad21a8 100644 --- a/test/idl/package.js +++ b/test/idl/package.js @@ -1,3 +1,4 @@ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import idlPackage from '../../packages/idl/package.json' with { type: 'json' }; diff --git a/test/idl/validate.js b/test/idl/validate.js index d5dd48f51e23..5e31acde46ed 100644 --- a/test/idl/validate.js +++ b/test/idl/validate.js @@ -9,6 +9,7 @@ * the package view, e.g. due to missing base interfaces. */ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -20,6 +21,7 @@ const curatedView = { name: 'curated', folder: path.join(scriptPath, '..', '..', 'curated', 'idl') }; + const packageView = { name: '@webref/idl package', folder: path.join(scriptPath, '..', '..', 'packages', 'idl') @@ -40,44 +42,39 @@ function validate(ast) { assert.fail(message); } -describe(`The ${curatedView.name} view of Web IDL extracts`, function () { - before(async () => { - const all = await idl.parseAll(curatedView.folder); +describe(`The ${curatedView.name} view of Web IDL extracts`, async function () { + let all; + try { + all = await idl.parseAll({folder: curatedView.folder}); + } catch (err) { + it('contains data that can be parsed with webidl2.js', () => {throw err ;}); + }; - describe(`The ${curatedView.name} view of Web IDL extracts`, function () { - for (const [spec, ast] of Object.entries(all)) { - it(`contains valid Web IDL for ${spec}`, function () { - validate(ast); - }); - } + for (const [spec, ast] of Object.entries(all)) { + it(`contains valid Web IDL for ${spec}`, function () { + validate(ast); }); - - describe(`The combined Web IDL in the ${curatedView.name} view`, function () { - it('is valid Web IDL', function () { - this.slow(1000); - validate(Object.values(all).flat()); - }); + } + describe(`The combined Web IDL in the ${curatedView.name} view`, function () { + it('is valid Web IDL', function () { + validate(Object.values(all).flat()); }); }); - - // Dummy test needed for "before" to run and register late tests - // (test will fail if before function throws, e.g. because data is invalid) - it('contains data that can be parsed with webidl2.js', () => {}); }); - describe(`The ${packageView.name} view of Web IDL extracts`, async () => { - before(async () => { - const all = await idl.parseAll(packageView.folder); + let all; + try { + all = await idl.parseAll({folder: packageView.folder}); + } catch (err) { + it('contains data that can be parsed with webidl2.js', () => {throw err;}); + } - describe(`The combined Web IDL in the ${packageView.name} view`, function () { - it('is valid Web IDL', function () { - this.slow(1000); - validate(Object.values(all).flat()); - }); + describe(`The combined Web IDL in the ${packageView.name} view`, function () { + it('is valid Web IDL', function () { + validate(Object.values(all).flat()); }); }); - it('contains data that can be parsed with webidl2.js', () => {}); }); diff --git a/test/schemas.js b/test/schemas.js index 8b018fb3164d..816f37ee0eea 100644 --- a/test/schemas.js +++ b/test/schemas.js @@ -4,6 +4,7 @@ * The tests run against the curated view of the extracts. */ +import { describe, it } from 'node:test'; import { strict as assert } from 'node:assert'; import fs from 'node:fs'; import path from 'node:path';