Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 7, 2023
1 parent f691835 commit f589852
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap
Expand Up @@ -40,6 +40,14 @@ Time: <<REPLACED>>
Ran all test suites matching /native-esm.test.js/i."
`;
exports[`support re-exports from CJS of core module 1`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching /native-esm-core-cjs-reexport.test.js/i."
`;
exports[`supports top-level await 1`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand Down
14 changes: 14 additions & 0 deletions e2e/__tests__/nativeEsm.test.ts
Expand Up @@ -68,6 +68,20 @@ onNodeVersions('>=16.9.0', () => {
});
});

test('support re-exports from CJS of core module', () => {
const {exitCode, stderr, stdout} = runJest(
DIR,
['native-esm-core-cjs-reexport.test.js'],
{nodeOptions: '--experimental-vm-modules --no-warnings'},
);

const {summary} = extractSummary(stderr);

expect(summary).toMatchSnapshot();
expect(stdout).toBe('');
expect(exitCode).toBe(0);
});

test('runs WebAssembly (Wasm) test with native ESM', () => {
const {exitCode, stderr, stdout} = runJest(DIR, ['native-esm-wasm.test.js'], {
nodeOptions: '--experimental-vm-modules --no-warnings',
Expand Down
12 changes: 12 additions & 0 deletions e2e/native-esm/__tests__/native-esm-core-cjs-reexport.test.js
@@ -0,0 +1,12 @@
/**
* 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 {Constants} from '../coreReexport.js';

test('can reexport core CJS requires', () => {
expect(Constants).toHaveProperty('TLS1_VERSION');
});
1 change: 1 addition & 0 deletions e2e/native-esm/__tests__/native-esm.test.js
Expand Up @@ -46,6 +46,7 @@ test('should support importing node core modules', () => {
expect(JSON.parse(readFileSync(packageJsonPath, 'utf8'))).toEqual({
devDependencies: {
'discord.js': '14.3.0',
'iso-constants': '^0.1.2',
yargs: '^17.5.1',
},
jest: {
Expand Down
10 changes: 10 additions & 0 deletions e2e/native-esm/coreReexport.js
@@ -0,0 +1,10 @@
/**
* 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 isoConstants from 'iso-constants';

export const Constants = isoConstants;

This comment has been minimized.

Copy link
@kowalski

kowalski Feb 7, 2023

Contributor

Sorry, I'm not sure, but I think this is not re-export, is it?

I think re-export would be

export * from 'iso-constants`

The way it's written currently actually worked fine before the fix I think

This comment has been minimized.

Copy link
@kowalski

kowalski Feb 7, 2023

Contributor

Ah, nvm, I think I get it.
The problem is in iso-constant package itself.

This comment has been minimized.

Copy link
@SimenB

SimenB Feb 7, 2023

Author Member

yup 👍

1 change: 1 addition & 0 deletions e2e/native-esm/package.json
Expand Up @@ -2,6 +2,7 @@
"type": "module",
"devDependencies": {
"discord.js": "14.3.0",
"iso-constants": "^0.1.2",
"yargs": "^17.5.1"
},
"jest": {
Expand Down
8 changes: 8 additions & 0 deletions e2e/native-esm/yarn.lock
Expand Up @@ -234,6 +234,13 @@ __metadata:
languageName: node
linkType: hard

"iso-constants@npm:^0.1.2":
version: 0.1.2
resolution: "iso-constants@npm:0.1.2"
checksum: 5e59939d03b4603d9426704c4dea8c41a4db14a91e34273a1b129aa84e265d6a63456d3543e3be85f47cdf350be5359bd31c59566e5084bdaee618dc65843804
languageName: node
linkType: hard

"lodash.snakecase@npm:^4.1.1":
version: 4.1.1
resolution: "lodash.snakecase@npm:4.1.1"
Expand Down Expand Up @@ -287,6 +294,7 @@ __metadata:
resolution: "root-workspace-0b6124@workspace:."
dependencies:
discord.js: 14.3.0
iso-constants: ^0.1.2
yargs: ^17.5.1
languageName: unknown
linkType: soft
Expand Down

0 comments on commit f589852

Please sign in to comment.