mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test_runner: add support for null and date value output
PR-URL: https://github.com/nodejs/node/pull/51920 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
29f09f05f7
commit
956ee74c7e
8 files changed
+173
-17
No files matched your search
@@ -3,6 +3,7 @@ const {
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypeJoin,
|
||||
ArrayPrototypePush,
|
||||
DatePrototypeToISOString,
|
||||
ObjectEntries,
|
||||
RegExpPrototypeSymbolReplace,
|
||||
RegExpPrototypeSymbolSplit,
|
||||
@@ -125,24 +126,28 @@ function tapEscape(input) {
|
||||
}
|
||||
|
||||
function jsToYaml(indent, name, value, seen) {
|
||||
if (value === null || value === undefined) {
|
||||
if (value === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
const prefix = `${indent} ${name}: `;
|
||||
const prefix = `${indent} ${name}:`;
|
||||
|
||||
if (value === null) {
|
||||
return `${prefix} ~\n`;
|
||||
}
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
if (typeof value !== 'string') {
|
||||
return `${prefix}${inspectWithNoCustomRetry(value, inspectOptions)}\n`;
|
||||
return `${prefix} ${inspectWithNoCustomRetry(value, inspectOptions)}\n`;
|
||||
}
|
||||
|
||||
const lines = RegExpPrototypeSymbolSplit(kLineBreakRegExp, value);
|
||||
|
||||
if (lines.length === 1) {
|
||||
return `${prefix}${inspectWithNoCustomRetry(value, inspectOptions)}\n`;
|
||||
return `${prefix} ${inspectWithNoCustomRetry(value, inspectOptions)}\n`;
|
||||
}
|
||||
|
||||
let str = `${prefix}|-\n`;
|
||||
let str = `${prefix} |-\n`;
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
str += `${indent} ${lines[i]}\n`;
|
||||
@@ -154,11 +159,16 @@ function jsToYaml(indent, name, value, seen) {
|
||||
seen.add(value);
|
||||
const entries = ObjectEntries(value);
|
||||
const isErrorObj = isError(value);
|
||||
let result = '';
|
||||
let propsIndent = indent;
|
||||
let result = '';
|
||||
|
||||
if (name != null) {
|
||||
result += `${indent} ${name}:\n`;
|
||||
result += prefix;
|
||||
if (internalBinding('types').isDate(value)) {
|
||||
// YAML uses the ISO-8601 standard to express dates.
|
||||
result += ' ' + DatePrototypeToISOString(value);
|
||||
}
|
||||
result += '\n';
|
||||
propsIndent += ' ';
|
||||
}
|
||||
|
||||
|
||||
+30
-2
@@ -422,12 +422,19 @@ Error [ERR_TEST_FAILURE]: bar
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" failure="Expected values to be loosely deep-equal:{ bar: 1, boo: [ 1 ], foo: 1}should loosely deep-equal{ boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] }}">
|
||||
<failure type="testCodeFailure" message="Expected values to be loosely deep-equal:{ bar: 1, boo: [ 1 ], foo: 1}should loosely deep-equal{ boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] }}">
|
||||
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" failure="Expected values to be loosely deep-equal:{ bar: 1, baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], foo: 1}should loosely deep-equal{ baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] }}">
|
||||
<failure type="testCodeFailure" message="Expected values to be loosely deep-equal:{ bar: 1, baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], foo: 1}should loosely deep-equal{ baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] }}">
|
||||
[Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal:
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -437,6 +444,13 @@ Error [ERR_TEST_FAILURE]: bar
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -451,6 +465,13 @@ should loosely deep-equal
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -460,6 +481,13 @@ should loosely deep-equal
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
|
||||
+9
-2
@@ -695,6 +695,13 @@ DA:389,1
|
||||
DA:390,1
|
||||
DA:391,1
|
||||
DA:392,1
|
||||
LH:390
|
||||
LF:392
|
||||
DA:393,1
|
||||
DA:394,1
|
||||
DA:395,1
|
||||
DA:396,1
|
||||
DA:397,1
|
||||
DA:398,1
|
||||
DA:399,1
|
||||
LH:397
|
||||
LF:399
|
||||
end_of_record
|
||||
+8
-1
@@ -383,8 +383,15 @@ test('assertion errors display actual and expected properly', async () => {
|
||||
const tmpLimit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 1;
|
||||
const boo = [1];
|
||||
const baz = {
|
||||
date: new Date(0),
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined,
|
||||
}
|
||||
try {
|
||||
assert.deepEqual({ foo: 1, bar: 1, boo }, { boo, circular }); // eslint-disable-line no-restricted-properties
|
||||
assert.deepEqual({ foo: 1, bar: 1, boo, baz }, { boo, baz, circular }); // eslint-disable-line no-restricted-properties
|
||||
} catch (err) {
|
||||
Error.stackTraceLimit = tmpLimit;
|
||||
throw err;
|
||||
|
||||
@@ -643,6 +643,13 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -652,6 +659,13 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -665,6 +679,11 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
expected:
|
||||
boo:
|
||||
0: 1
|
||||
baz:
|
||||
date: 1970-01-01T00:00:00.000Z
|
||||
null: ~
|
||||
number: 1
|
||||
string: 'Hello'
|
||||
circular:
|
||||
bar: 2
|
||||
c: <Circular>
|
||||
@@ -673,6 +692,11 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
bar: 1
|
||||
boo:
|
||||
0: 1
|
||||
baz:
|
||||
date: 1970-01-01T00:00:00.000Z
|
||||
null: ~
|
||||
number: 1
|
||||
string: 'Hello'
|
||||
operator: 'deepEqual'
|
||||
stack: |-
|
||||
*
|
||||
|
||||
@@ -643,6 +643,13 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -652,6 +659,13 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -665,6 +679,11 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
expected:
|
||||
boo:
|
||||
0: 1
|
||||
baz:
|
||||
date: 1970-01-01T00:00:00.000Z
|
||||
null: ~
|
||||
number: 1
|
||||
string: 'Hello'
|
||||
circular:
|
||||
bar: 2
|
||||
c: <Circular>
|
||||
@@ -673,6 +692,11 @@ not ok 61 - assertion errors display actual and expected properly
|
||||
bar: 1
|
||||
boo:
|
||||
0: 1
|
||||
baz:
|
||||
date: 1970-01-01T00:00:00.000Z
|
||||
null: ~
|
||||
number: 1
|
||||
string: 'Hello'
|
||||
operator: 'deepEqual'
|
||||
stack: |-
|
||||
*
|
||||
|
||||
@@ -263,6 +263,13 @@
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -272,6 +279,13 @@
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -536,6 +550,13 @@
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -545,6 +566,13 @@
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
|
||||
+32
-4
@@ -263,6 +263,13 @@
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -272,6 +279,13 @@
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -283,8 +297,8 @@
|
||||
* {
|
||||
generatedMessage: true,
|
||||
code: 'ERR_ASSERTION',
|
||||
actual: { foo: 1, bar: 1, boo: [ 1 ] },
|
||||
expected: { boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] } },
|
||||
actual: { foo: 1, bar: 1, boo: [ 1 ], baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined } },
|
||||
expected: { boo: [ 1 ], baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, circular: <ref *1> { bar: 2, c: [Circular *1] } },
|
||||
operator: 'deepEqual'
|
||||
}
|
||||
|
||||
@@ -536,6 +550,13 @@
|
||||
|
||||
{
|
||||
bar: 1,
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -545,6 +566,13 @@
|
||||
should loosely deep-equal
|
||||
|
||||
{
|
||||
baz: {
|
||||
date: 1970-01-01T00:00:00.000Z,
|
||||
null: null,
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined
|
||||
},
|
||||
boo: [
|
||||
1
|
||||
],
|
||||
@@ -556,8 +584,8 @@
|
||||
* {
|
||||
generatedMessage: true,
|
||||
code: 'ERR_ASSERTION',
|
||||
actual: { foo: 1, bar: 1, boo: [ 1 ] },
|
||||
expected: { boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] } },
|
||||
actual: { foo: 1, bar: 1, boo: [ 1 ], baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined } },
|
||||
expected: { boo: [ 1 ], baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, circular: <ref *1> { bar: 2, c: [Circular *1] } },
|
||||
operator: 'deepEqual'
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user