From 7d4e3ed0f50c9762c306f4d0f033ea2659945565 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 5 Dec 2022 18:20:25 +0800 Subject: [PATCH] fix: don't escape "\" in diff view (#2430) --- packages/vitest/src/integrations/chai/jest-matcher-utils.ts | 2 ++ test/core/test/basic.test.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/packages/vitest/src/integrations/chai/jest-matcher-utils.ts b/packages/vitest/src/integrations/chai/jest-matcher-utils.ts index a3b6d5ce56c0..e0f017f37883 100644 --- a/packages/vitest/src/integrations/chai/jest-matcher-utils.ts +++ b/packages/vitest/src/integrations/chai/jest-matcher-utils.ts @@ -109,6 +109,7 @@ export function stringify(object: unknown, maxDepth = 10, options?: PrettyFormat try { result = prettyFormat(object, { maxDepth, + escapeString: false, // min: true, plugins: PLUGINS, ...options, @@ -118,6 +119,7 @@ export function stringify(object: unknown, maxDepth = 10, options?: PrettyFormat result = prettyFormat(object, { callToJSON: false, maxDepth, + escapeString: false, // min: true, plugins: PLUGINS, ...options, diff --git a/test/core/test/basic.test.ts b/test/core/test/basic.test.ts index b3e30d675a2b..d775423c442b 100644 --- a/test/core/test/basic.test.ts +++ b/test/core/test/basic.test.ts @@ -58,3 +58,8 @@ it.fails('deprecated done callback', (done) => { // @ts-expect-error deprecated done callback is not typed done() }) + +test('escaping', () => { + expect(['\\123']).toEqual(['\\123']) + expect('\\123').toEqual('\\123') +})