From a81bef441d4da1a9f86c62244326eb0e3f9d5030 Mon Sep 17 00:00:00 2001 From: AWS CDK Automation <43080478+aws-cdk-automation@users.noreply.github.com> Date: Mon, 16 Dec 2024 08:29:03 -0800 Subject: [PATCH] chore: `Match.arrEq` is not defined for arrays containing `undefined` (backport #1589) (#1592) # Backport This will backport the following commits from `main` to `maintenance/v5.6`: - [chore: `Match.arrEq` is not defined for arrays containing `undefined` (#1589)](https://github.com/aws/jsii-compiler/pull/1589) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Rico Hermans --- test/tsconfig/validator.test.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/tsconfig/validator.test.ts b/test/tsconfig/validator.test.ts index 910d3e71..96103e1e 100644 --- a/test/tsconfig/validator.test.ts +++ b/test/tsconfig/validator.test.ts @@ -91,11 +91,13 @@ describe('Built-in matchers', () => { }); describe('Match.arrEq', () => { + const arrayEl = anythingExceptUndefined(); + test('pass', () => { fc.assert( fc.property( fc - .array(fc.anything({ maxDepth: 0 })) + .array(arrayEl) .chain((expected) => fc.tuple( fc.constant(expected), @@ -111,10 +113,10 @@ describe('Built-in matchers', () => { test('fail', () => { fc.assert( fc.property( - fc.uniqueArray(fc.anything(), { + fc.uniqueArray(arrayEl, { minLength: 1, }), - fc.array(fc.anything()), + fc.array(arrayEl), (possible, actualBase) => { const expected = possible.slice(0, -1); const actual = [...actualBase, possible.at(-1)]; @@ -229,3 +231,7 @@ describe('Object Validator', () => { ); }); }); + +function anythingExceptUndefined() { + return fc.anything().filter((x) => x !== undefined); +}