From dcff11e50e14934e548c2b08e8b45cb5e91968dd Mon Sep 17 00:00:00 2001 From: Alexander Kachkaev Date: Thu, 27 Oct 2022 23:16:19 +0100 Subject: [PATCH] Simplify tests --- .../__snapshots__/nativeEsm.test.ts.snap | 8 +++++ e2e/__tests__/nativeEsm.test.ts | 12 +++++++ e2e/__tests__/nativeEsmWasm.test.ts | 34 ------------------ .../answer.wasm => native-esm/42.wasm} | Bin .../__tests__/native-esm-wasm.test.js} | 4 +-- 5 files changed, 22 insertions(+), 36 deletions(-) delete mode 100644 e2e/__tests__/nativeEsmWasm.test.ts rename e2e/{native-esm-wasm/answer.wasm => native-esm/42.wasm} (100%) rename e2e/{native-esm-wasm/__tests__/answer.test.js => native-esm/__tests__/native-esm-wasm.test.js} (92%) diff --git a/e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap b/e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap index 1e6cd80fa82e..648efbfd14c9 100644 --- a/e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap +++ b/e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap @@ -8,6 +8,14 @@ Time: <> Ran all test suites matching /native-esm-deep-cjs-reexport.test.js/i." `; +exports[`runs WASM test with native ESM 1`] = ` +"Test Suites: 1 passed, 1 total +Tests: 4 passed, 4 total +Snapshots: 0 total +Time: <> +Ran all test suites matching /native-esm-wasm.test.js/i." +`; + exports[`runs test with native ESM 1`] = ` "Test Suites: 1 passed, 1 total Tests: 33 passed, 33 total diff --git a/e2e/__tests__/nativeEsm.test.ts b/e2e/__tests__/nativeEsm.test.ts index a636fdf1344a..f5227089c623 100644 --- a/e2e/__tests__/nativeEsm.test.ts +++ b/e2e/__tests__/nativeEsm.test.ts @@ -67,3 +67,15 @@ onNodeVersions('>=16.9.0', () => { expect(exitCode).toBe(0); }); }); + +test('runs WASM test with native ESM', () => { + const {exitCode, stderr, stdout} = runJest(DIR, ['native-esm-wasm.test.js'], { + nodeOptions: '--experimental-vm-modules --no-warnings', + }); + + const {summary} = extractSummary(stderr); + + expect(summary).toMatchSnapshot(); + expect(stdout).toBe(''); + expect(exitCode).toBe(0); +}); diff --git a/e2e/__tests__/nativeEsmWasm.test.ts b/e2e/__tests__/nativeEsmWasm.test.ts deleted file mode 100644 index 4b5c2ad313ec..000000000000 --- a/e2e/__tests__/nativeEsmWasm.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import {resolve} from 'path'; -import {json as runJest} from '../runJest'; - -const DIR = resolve(__dirname, '../native-esm-wasm'); - -test('runs WASM test with native ESM', () => { - const {exitCode, json} = runJest(DIR, [], { - nodeOptions: '--experimental-vm-modules --no-warnings', - }); - - expect(exitCode).toBe(0); - - expect(json.numTotalTests).toBe(4); - expect(json.numPassedTests).toBe(4); -}); - -test('runs WASM test with native ESM with --experimental-wasm-modules flag', () => { - const {exitCode, json} = runJest(DIR, [], { - nodeOptions: - '--experimental-vm-modules --experimental-wasm-modules --no-warnings', - }); - - expect(exitCode).toBe(0); - - expect(json.numTotalTests).toBe(4); - expect(json.numPassedTests).toBe(4); -}); diff --git a/e2e/native-esm-wasm/answer.wasm b/e2e/native-esm/42.wasm similarity index 100% rename from e2e/native-esm-wasm/answer.wasm rename to e2e/native-esm/42.wasm diff --git a/e2e/native-esm-wasm/__tests__/answer.test.js b/e2e/native-esm/__tests__/native-esm-wasm.test.js similarity index 92% rename from e2e/native-esm-wasm/__tests__/answer.test.js rename to e2e/native-esm/__tests__/native-esm-wasm.test.js index 5d3771c7c8b5..17d4f4700823 100644 --- a/e2e/native-esm-wasm/__tests__/answer.test.js +++ b/e2e/native-esm/__tests__/native-esm-wasm.test.js @@ -9,9 +9,9 @@ // eslint-disable-next-line no-restricted-imports import {readFileSync} from 'fs'; // The file was generated by wasm-pack -import {getAnswer} from '../answer.wasm'; +import {getAnswer} from '../42.wasm'; -const wasmFileBuffer = readFileSync('answer.wasm'); +const wasmFileBuffer = readFileSync('42.wasm'); test('supports native wasm imports', () => { expect(getAnswer()).toBe(42);