Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING(testing/snapshot): change tab char serialization #3447

Merged
merged 2 commits into from
Jul 29, 2023

Conversation

wafuwafu13
Copy link
Contributor

Example test

Deno.test("Snapshot Test - Default serializer", async (t) => {
  await assertSnapshot(t, "a\nb\tc");
});

Before

snapshot[`Snapshot Test - Default serializer 1`] = `
"a
b\\tc"
`;

After

snapshot[`Snapshot Test - Default serializer 1`] = `
"a
b	c"
`;

@wafuwafu13 wafuwafu13 requested a review from kt3k as a code owner June 13, 2023 20:23
@kt3k kt3k changed the title feat(testing): serialize tabs by default in snapshots BREAKING(testing/snapshot): change tab char serialization Jun 14, 2023
@@ -204,7 +204,7 @@ export function serialize(actual: unknown): string {
compact: false,
iterableLimit: Infinity,
strAbbreviateSize: Infinity,
}).replace(/\\n/g, "\n");
}).replace(/\\n/g, "\n").replace(/\\t/g, "\t");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added option (escapeSequences) for disabling the escape of this kind of chars in denoland/deno#19337. Let's use that option instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use escapeSequences: false

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the initial idea!

@kt3k kt3k merged commit 428154a into denoland:main Jul 29, 2023
lambdalisue added a commit to lambdalisue/vim-gin that referenced this pull request Aug 6, 2023
@lambdalisue
Copy link
Contributor

lambdalisue commented Aug 6, 2023

Note that this change made it impossible for the same snapshot file to coexist on the old Deno and the new Deno...
The specific version is not known, but Deno without denoland/deno#19337 still produces escaped output, so the old and new snapshots will be different.


I worked around this by specifying a custom serializer, as shown in the link below. However, as a user, I would have liked to have been able to optionally set a backward compatibility guarantee when making destructive changes. I forgot that deno_std is still v0.x so I should not expect backward compatiblity.

lambdalisue/vim-gin@3ecec96

lambdalisue added a commit to lambdalisue/vim-gin that referenced this pull request Aug 6, 2023
lambdalisue added a commit to lambdalisue/vim-gin that referenced this pull request Aug 6, 2023
lambdalisue added a commit to lambdalisue/vim-gin that referenced this pull request Aug 6, 2023
lambdalisue added a commit to lambdalisue/vim-gin that referenced this pull request Aug 6, 2023
Because of the comment below, we cannot test features prior to Deno v1.34.

denoland/std#3447 (comment)
lambdalisue added a commit to lambdalisue/vim-gin that referenced this pull request Aug 6, 2023
Based on the Deno.inspect enhancements added in Deno 1.36, assertSnapshot has undergone
a destructive change, so those supporting Deno 1.36 or earlier can only specify a custom
serializer to ensure backward compatibility.

denoland/std#3447 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants