From 4dc8dcf5bcf6f673b8310622f06d506f3b72d06a Mon Sep 17 00:00:00 2001 From: dpiercey Date: Wed, 7 Aug 2024 11:08:42 -0700 Subject: [PATCH] chore: remove stack trace from error snapshots --- .../const-mutation-error/web.render.error.expected.txt | 3 +-- .../web.step-0.error.expected.txt | 5 +---- .../web.step-0.error.expected.txt | 5 +---- .../web.step-0.error.expected.txt | 5 +---- .../node.render.error.expected.txt | 5 +---- .../web.render.error.expected.txt | 3 +-- .../node.render.error.expected.txt | 6 +----- .../web.render.error.expected.txt | 4 +--- .../error-read-before-mount/node.render.error.expected.txt | 3 +-- .../error-read-before-mount/web.render.error.expected.txt | 3 +-- src/__tests__/snapshot.ts | 3 +-- 11 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/__tests__/fixtures/const/__snapshots__/const-mutation-error/web.render.error.expected.txt b/src/__tests__/fixtures/const/__snapshots__/const-mutation-error/web.render.error.expected.txt index 6a9b7e8..448179e 100644 --- a/src/__tests__/fixtures/const/__snapshots__/const-mutation-error/web.render.error.expected.txt +++ b/src/__tests__/fixtures/const/__snapshots__/const-mutation-error/web.render.error.expected.txt @@ -1,2 +1 @@ -TypeError: Cannot add property fullName, object is not extensible - at /src/__tests__/fixture.ts \ No newline at end of file +TypeError: Cannot add property fullName, object is not extensible \ No newline at end of file diff --git a/src/__tests__/fixtures/get-and-set/__snapshots__/get-read-assign-to-missing-context/web.step-0.error.expected.txt b/src/__tests__/fixtures/get-and-set/__snapshots__/get-read-assign-to-missing-context/web.step-0.error.expected.txt index 44a8ba6..9a98371 100644 --- a/src/__tests__/fixtures/get-and-set/__snapshots__/get-read-assign-to-missing-context/web.step-0.error.expected.txt +++ b/src/__tests__/fixtures/get-and-set/__snapshots__/get-read-assign-to-missing-context/web.step-0.error.expected.txt @@ -1,4 +1 @@ -Error: Assignment to constant variable. - at /src/__tests__/fire-event.ts - at /src/__tests__/fixtures/get-and-set/index.test.ts - at /src/__tests__/fixture.ts \ No newline at end of file +Error: Assignment to constant variable. \ No newline at end of file diff --git a/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-const-set/web.step-0.error.expected.txt b/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-const-set/web.step-0.error.expected.txt index 44a8ba6..9a98371 100644 --- a/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-const-set/web.step-0.error.expected.txt +++ b/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-const-set/web.step-0.error.expected.txt @@ -1,4 +1 @@ -Error: Assignment to constant variable. - at /src/__tests__/fire-event.ts - at /src/__tests__/fixtures/get-and-set/index.test.ts - at /src/__tests__/fixture.ts \ No newline at end of file +Error: Assignment to constant variable. \ No newline at end of file diff --git a/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-nested-const-set/web.step-0.error.expected.txt b/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-nested-const-set/web.step-0.error.expected.txt index 44a8ba6..9a98371 100644 --- a/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-nested-const-set/web.step-0.error.expected.txt +++ b/src/__tests__/fixtures/get-and-set/__snapshots__/get-set-assign-to-nested-const-set/web.step-0.error.expected.txt @@ -1,4 +1 @@ -Error: Assignment to constant variable. - at /src/__tests__/fire-event.ts - at /src/__tests__/fixtures/get-and-set/index.test.ts - at /src/__tests__/fixture.ts \ No newline at end of file +Error: Assignment to constant variable. \ No newline at end of file diff --git a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/node.render.error.expected.txt b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/node.render.error.expected.txt index a2e3044..d07d6cf 100644 --- a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/node.render.error.expected.txt +++ b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/node.render.error.expected.txt @@ -1,4 +1 @@ -ReferenceError: Cannot access 'x' before initialization - at /src/transform/hoist-tag-vars/index.ts - at /src/__tests__/fixtures/misc/hoisting/templates/error-hoisting-maybe-sync-read-before-with-custom-tag.marko - at /src/__tests__/fixture.ts \ No newline at end of file +ReferenceError: Cannot access 'x' before initialization \ No newline at end of file diff --git a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/web.render.error.expected.txt b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/web.render.error.expected.txt index 7475a60..d07d6cf 100644 --- a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/web.render.error.expected.txt +++ b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before-with-custom-tag/web.render.error.expected.txt @@ -1,2 +1 @@ -ReferenceError: Cannot access 'x' before initialization - at /src/__tests__/fixtures/misc/hoisting/templates/error-hoisting-maybe-sync-read-before-with-custom-tag.marko \ No newline at end of file +ReferenceError: Cannot access 'x' before initialization \ No newline at end of file diff --git a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/node.render.error.expected.txt b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/node.render.error.expected.txt index cc9c1a4..d07d6cf 100644 --- a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/node.render.error.expected.txt +++ b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/node.render.error.expected.txt @@ -1,5 +1 @@ -ReferenceError: Cannot access 'x' before initialization - at /src/transform/hoist-tag-vars/index.ts - at /src/__tests__/fixtures/misc/hoisting/templates/error-hoisting-maybe-sync-read-before.marko - at /src/__tests__/fixtures/misc/hoisting/templates/error-hoisting-maybe-sync-read-before.marko - at /src/__tests__/fixture.ts \ No newline at end of file +ReferenceError: Cannot access 'x' before initialization \ No newline at end of file diff --git a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/web.render.error.expected.txt b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/web.render.error.expected.txt index d5b9870..d07d6cf 100644 --- a/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/web.render.error.expected.txt +++ b/src/__tests__/fixtures/misc/hoisting/__snapshots__/misc-hoisting/error-maybe-sync-read-before/web.render.error.expected.txt @@ -1,3 +1 @@ -ReferenceError: Cannot access 'x' before initialization - at /src/__tests__/fixtures/misc/hoisting/templates/error-hoisting-maybe-sync-read-before.marko - at /src/__tests__/fixtures/misc/hoisting/templates/error-hoisting-maybe-sync-read-before.marko \ No newline at end of file +ReferenceError: Cannot access 'x' before initialization \ No newline at end of file diff --git a/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/node.render.error.expected.txt b/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/node.render.error.expected.txt index 78c34fd..b8deb64 100644 --- a/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/node.render.error.expected.txt +++ b/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/node.render.error.expected.txt @@ -1,2 +1 @@ -Error: Cannot read an element reference while rendering. - at /src/__tests__/fixture.ts \ No newline at end of file +Error: Cannot read an element reference while rendering. \ No newline at end of file diff --git a/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/web.render.error.expected.txt b/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/web.render.error.expected.txt index 78c34fd..b8deb64 100644 --- a/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/web.render.error.expected.txt +++ b/src/__tests__/fixtures/misc/native-tag-var/__snapshots__/misc-native-tag-vars/error-read-before-mount/web.render.error.expected.txt @@ -1,2 +1 @@ -Error: Cannot read an element reference while rendering. - at /src/__tests__/fixture.ts \ No newline at end of file +Error: Cannot read an element reference while rendering. \ No newline at end of file diff --git a/src/__tests__/snapshot.ts b/src/__tests__/snapshot.ts index efd24b8..0c0d168 100644 --- a/src/__tests__/snapshot.ts +++ b/src/__tests__/snapshot.ts @@ -144,8 +144,7 @@ function format(data: any): string { // eslint-disable-next-line no-control-regex .replace(/\x1B[[(?);]{0,2}(;?\d)*./g, "") .replaceAll(process.cwd(), "") - .replace(/\r?\n +at (?![/\\]src[/\\])[^\n]+$/gm, "") - .replace(/(\r?\n +at [/\\]src[/\\].*[^\n]):\d+:\d+$/gm, "$1") + .replace(/\r?\n +at [^\n]+$/gm, "") ); } }