test: make test-runner-assert more robust

PR-URL: https://github.com/nodejs/node/pull/55036
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Aviv Keller 2024-09-22 18:27:36 -04:00 committed by GitHub
parent 1c61a83444
commit 8b70e6bdee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,28 +1,16 @@
'use strict';
require('../common');
const { deepStrictEqual } = require('node:assert');
const assert = require('node:assert');
const test = require('node:test');
const uncopiedKeys = [
'AssertionError',
'CallTracker',
'strict',
];
test('only methods from node:assert are on t.assert', (t) => {
deepStrictEqual(Object.keys(t.assert).sort(), [
'deepEqual',
'deepStrictEqual',
'doesNotMatch',
'doesNotReject',
'doesNotThrow',
'equal',
'fail',
'ifError',
'match',
'notDeepEqual',
'notDeepStrictEqual',
'notEqual',
'notStrictEqual',
'ok',
'rejects',
'strictEqual',
'throws',
]);
const expectedKeys = Object.keys(assert).filter((key) => !uncopiedKeys.includes(key)).sort();
assert.deepStrictEqual(Object.keys(t.assert).sort(), expectedKeys);
});
test('t.assert.ok correctly parses the stacktrace', (t) => {