From ff61ddc74362039fb64442b61fbcf11f95dafd05 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 27 Oct 2024 19:34:21 +0100 Subject: [PATCH] chore: apply review suggestions --- test/support/seeded-runs.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/support/seeded-runs.ts b/test/support/seeded-runs.ts index 30f5e39ddc3..66d6df3c4dd 100644 --- a/test/support/seeded-runs.ts +++ b/test/support/seeded-runs.ts @@ -241,7 +241,9 @@ class TestGenerator< const tester: MethodTester = { it(name: string, ...args: Parameters) { expectVariantNotTested(name); - const extraStackFrames = collectExtraStackFrames(name.length + 7); + const extraStackFrames = collectExtraStackFrames( + /* t. */ `it('${name}', `.length // ...args) + ); vi_it(name, () => callAndVerify(method, args, extraStackFrames)); return tester; }, @@ -251,7 +253,9 @@ class TestGenerator< ...args: Parameters ) { expectVariantNotTested(name); - const extraStackFrames = collectExtraStackFrames(name.length + 7); + const extraStackFrames = collectExtraStackFrames( + /* t. */ `itRepeated('${name}', ${repetitions}, `.length // ...args) + ); vi_it(name, () => callAndVerify(method, args, extraStackFrames, repetitions) ); @@ -318,7 +322,7 @@ function collectExtraStackFrames(extraOffset: number = 0): () => string[] { return () => stack .split('\n') - .map((e) => e.replaceAll('\\', '/')) + .map((e) => e.replaceAll('\\', '/')) // Windows to Linux paths .filter((e) => e.includes('/test/')) // exclude node_modules .filter((e) => !e.includes('/test/support/')) // exclude this file .map((e) => @@ -327,10 +331,10 @@ function collectExtraStackFrames(extraOffset: number = 0): () => string[] { } /** - * Modifies the error stack to include the given additional stack frames. + * Modifies the error stack to include the given additional stack frames after the last occurrence of this file. * * @param error The error to modify. - * @param extraStackFrames The additional stack frames to add after this file. + * @param extraStackFrames The additional stack frames to add. */ function patchExtraStackFrames( error: unknown, @@ -339,7 +343,9 @@ function patchExtraStackFrames( if (error instanceof Error && error.stack != null) { const stack = error.stack.split('\n'); const index = stack.findLastIndex((e) => - e.replaceAll('\\', '/').includes('/test/support/') + e + .replaceAll('\\', '/') // Windows to Linux paths + .includes('/test/support/') ); stack.splice(index + 1, 0, ...extraStackFrames()); error.stack = stack.join('\n');