From 30a4d633aaf0d9e271b514fc5f5a5021483a764e Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 18 Mar 2025 14:30:21 -0400 Subject: [PATCH 1/6] chore: improve assertion with expected path --- test/tools/unified-spec-runner/match.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 931ba1c9ecc..24f98bbc2ef 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -263,7 +263,7 @@ export function resultCheck( } if (typeof actual !== 'object') { - expect.fail('Expected actual value to be an object'); + expect.fail(`Expected actual value to be an object at: ${path.join('')}`); } const expectedEntries = Object.entries(expected); From 19932e4e9471cea31819a337bfb0e4f22d7b49fe Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 18 Mar 2025 14:48:07 -0400 Subject: [PATCH 2/6] add inspect of actual --- test/tools/unified-spec-runner/match.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 24f98bbc2ef..a281ea95d6d 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -263,7 +263,9 @@ export function resultCheck( } if (typeof actual !== 'object') { - expect.fail(`Expected actual value to be an object at: ${path.join('')}`); + expect.fail( + `Expected actual value (${inspect(actual)}) to be an object at: ${path.join('')}` + ); } const expectedEntries = Object.entries(expected); From 38d59d8f9c15336d5dbf9b72fd5499baf326e490 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 18 Mar 2025 14:51:23 -0400 Subject: [PATCH 3/6] spicy chai --- test/tools/unified-spec-runner/match.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index a281ea95d6d..ef939aa00bf 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -262,20 +262,12 @@ export function resultCheck( return; } - if (typeof actual !== 'object') { - expect.fail( - `Expected actual value (${inspect(actual)}) to be an object at: ${path.join('')}` - ); - } + expect(actual, `Expected actual to be an object at: ${path.join('')}`).to.be.an('object'); const expectedEntries = Object.entries(expected); if (Array.isArray(expected)) { - if (!Array.isArray(actual)) { - expect.fail( - `expected value at ${path.join('.')} to be an array, but received ${inspect(actual)}` - ); - } + expect(actual, `Expected actual to be an array at: ${path.join('')}`).to.be.an('array'); for (const [index, value] of expectedEntries) { path.push(`[${index}]`); checkNestedDocuments(index, value, checkExtraKeys); From 50a883d836707e4b0804b8f283515a8ca5c0aa47 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 18 Mar 2025 15:10:13 -0400 Subject: [PATCH 4/6] chai latte --- test/tools/unified-spec-runner/match.ts | 5 +++-- test/unit/tools/unified_spec_runner.test.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index ef939aa00bf..0c43e096bb9 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -262,12 +262,13 @@ export function resultCheck( return; } - expect(actual, `Expected actual to be an object at: ${path.join('')}`).to.be.an('object'); + expect(actual, `Expected actual to be an object at: ${path.join('')}`).to.be.an( + Array.isArray(expected) ? 'array' : 'object' + ); const expectedEntries = Object.entries(expected); if (Array.isArray(expected)) { - expect(actual, `Expected actual to be an array at: ${path.join('')}`).to.be.an('array'); for (const [index, value] of expectedEntries) { path.push(`[${index}]`); checkNestedDocuments(index, value, checkExtraKeys); diff --git a/test/unit/tools/unified_spec_runner.test.ts b/test/unit/tools/unified_spec_runner.test.ts index 7ebee168590..513d85df76b 100644 --- a/test/unit/tools/unified_spec_runner.test.ts +++ b/test/unit/tools/unified_spec_runner.test.ts @@ -135,7 +135,7 @@ describe('Unified Spec Runner', function () { expect(() => resultCheckSpy(actual, expected, entitiesMap, [])).to.throw( AssertionError, - /Expected actual value to be an object/ + /to be an object/ ); }); }); From 4bf1384af70845e22e058ca84afb3ed23b570540 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 18 Mar 2025 17:21:34 -0400 Subject: [PATCH 5/6] chai latte --- test/tools/unified-spec-runner/match.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 0c43e096bb9..cca7fd55b6d 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -262,8 +262,11 @@ export function resultCheck( return; } - expect(actual, `Expected actual to be an object at: ${path.join('')}`).to.be.an( - Array.isArray(expected) ? 'array' : 'object' + expect( + actual, + `Expected actual (${inspect(actual)}) to be an ${Array.isArray(expected) ? 'array' : 'object'} at: ${path.join('')}` + ).to.satisfies(actual => + Array.isArray(expected) ? Array.isArray(actual) : typeof actual === 'object' ); const expectedEntries = Object.entries(expected); From f0be13b1605bb7b257b7ec75b45b2b57c5b00d50 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Wed, 19 Mar 2025 10:46:49 -0400 Subject: [PATCH 6/6] chai tea --- test/tools/unified-spec-runner/match.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index cca7fd55b6d..1b8d0d7836e 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -265,7 +265,7 @@ export function resultCheck( expect( actual, `Expected actual (${inspect(actual)}) to be an ${Array.isArray(expected) ? 'array' : 'object'} at: ${path.join('')}` - ).to.satisfies(actual => + ).to.satisfy(actual => Array.isArray(expected) ? Array.isArray(actual) : typeof actual === 'object' );