From deaaec3e1106fce9e1aad21768a07b99f60b4f23 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Mon, 27 Dec 2021 03:01:15 +0000 Subject: [PATCH] fix mistakes in test --- src/test/esm-loader.spec.ts | 6 +++--- tests/esm-import-assertions/importJson.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/esm-loader.spec.ts b/src/test/esm-loader.spec.ts index 894f86dad..0de0482c0 100644 --- a/src/test/esm-loader.spec.ts +++ b/src/test/esm-loader.spec.ts @@ -78,14 +78,14 @@ if (nodeSupportsImportAssertions) { test.suite('Supports import assertions', (test) => { test('Can import JSON using the appropriate flag and assertion', async (t) => { const { err, stdout } = await exec( - `${CMD_ESM_LOADER_WITHOUT_PROJECT} ./importJson.ts`, + `${CMD_ESM_LOADER_WITHOUT_PROJECT} --experimental-json-modules ./importJson.ts`, { cwd: resolve(TEST_DIR, 'esm-import-assertions'), } ); expect(err).toBe(null); - expect(stdout).toMatch( - 'A fuchsia car has 2 seats and the doors are open.`\nDone!' + expect(stdout.trim()).toBe( + 'A fuchsia car has 2 seats and the doors are open.\nDone!' ); }); }); diff --git a/tests/esm-import-assertions/importJson.ts b/tests/esm-import-assertions/importJson.ts index 3374c731a..b4446aa71 100644 --- a/tests/esm-import-assertions/importJson.ts +++ b/tests/esm-import-assertions/importJson.ts @@ -18,8 +18,8 @@ await import('./car.json').then( () => { throw new Error('should have thrown'); }, - (error: Error) => { - if (!error.message.includes('foo bar')) { + (error: any) => { + if (error.code !== 'ERR_IMPORT_ASSERTION_TYPE_MISSING') { throw error; } /* error is expected */