From bb2a69c8d0eb93c8ebb4d26825ff6b1330da7052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A3=E9=87=8C=E5=A5=BD=E8=84=8F=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5?= Date: Sat, 13 Aug 2022 21:06:29 +0800 Subject: [PATCH] fix(pnpm/test): add escape characters (#5193) * fix(pnpm/test): add escape characters * test: refactor close #5192 Co-authored-by: Zoltan Kochan --- packages/pnpm/test/cli.ts | 2 +- packages/read-project-manifest/test/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/pnpm/test/cli.ts b/packages/pnpm/test/cli.ts index 7662fa0cb3..287df2f35c 100644 --- a/packages/pnpm/test/cli.ts +++ b/packages/pnpm/test/cli.ts @@ -18,7 +18,7 @@ test('some commands pass through to npm', () => { const result = execPnpmSync(['dist-tag', 'ls', 'is-positive']) expect(result.status).toBe(0) - expect(result.stdout.toString()).not.toMatch(/Usage: pnpm [command] [flags]/) + expect(result.stdout.toString()).not.toContain('Usage: pnpm [command] [flags]') }) test('installs in the folder where the package.json file is', async () => { diff --git a/packages/read-project-manifest/test/index.ts b/packages/read-project-manifest/test/index.ts index b3031b637a..fb6a296a56 100644 --- a/packages/read-project-manifest/test/index.ts +++ b/packages/read-project-manifest/test/index.ts @@ -118,8 +118,8 @@ test('fail on invalid JSON', async () => { expect(err).toBeTruthy() expect(err['code']).toBe('ERR_PNPM_JSON_PARSE') - // eslint-disable-next-line - expect(err.message).toMatch(/^Unexpected string in JSON at position 20 while parsing \'{ "name": "foo" "version": "1.0.0"}\' in /) + + expect(err.message).toContain('Unexpected string in JSON at position 20 while parsing \'{ "name": "foo" "version": "1.0.0"}\' in ') }) test('fail on invalid JSON5', async () => {