mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
ff001c12b0
This is first in a hoped-for series of moves away from a monolithic common.js that is loaded for every test and towards a more modular approach. (In the end, common.js will hopefully contain checks for variables leaking into the global space and perhaps some of the more ubiquitous functions like common.mustCall().) Move the WPT testing code to its own module. PR-URL: https://github.com/nodejs/node/pull/12736 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
31 lines
848 B
JavaScript
31 lines
848 B
JavaScript
/* eslint-disable required-modules */
|
|
'use strict';
|
|
|
|
const assert = require('assert');
|
|
|
|
// https://github.com/w3c/testharness.js/blob/master/testharness.js
|
|
module.exports = {
|
|
test: (fn, desc) => {
|
|
try {
|
|
fn();
|
|
} catch (err) {
|
|
console.error(`In ${desc}:`);
|
|
throw err;
|
|
}
|
|
},
|
|
assert_equals: assert.strictEqual,
|
|
assert_true: (value, message) => assert.strictEqual(value, true, message),
|
|
assert_false: (value, message) => assert.strictEqual(value, false, message),
|
|
assert_throws: (code, func, desc) => {
|
|
assert.throws(func, function(err) {
|
|
return typeof err === 'object' &&
|
|
'name' in err &&
|
|
err.name.startsWith(code.name);
|
|
}, desc);
|
|
},
|
|
assert_array_equals: assert.deepStrictEqual,
|
|
assert_unreached(desc) {
|
|
assert.fail(`Reached unreachable code: ${desc}`);
|
|
}
|
|
};
|