Skip to content

Commit 1f2d271

Browse files
committed
expand node-esm tests
1 parent 89a7efc commit 1f2d271

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

.eslintrc.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ rules:
443443

444444
overrides:
445445
- files:
446-
- 'integrationTests/webpack-esm/*.js'
447-
- 'integrationTests/node-esm/*.js'
446+
- 'integrationTests/node-esm/**/*.js'
448447
parserOptions:
449448
sourceType: module
450449
- files: '**/*.ts'

integrationTests/node-esm/index.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
/* eslint-disable node/no-missing-import, import/no-unresolved */
1+
/* eslint-disable node/no-missing-import, import/no-unresolved, node/no-unsupported-features/es-syntax */
22

33
import { deepStrictEqual, strictEqual } from 'assert';
44

5-
// Regular import
5+
import { version } from 'version';
6+
import { schema } from 'schema';
7+
68
import { graphqlSync } from 'graphql';
7-
// Import with explicit extension
8-
import { version } from 'graphql/version.js';
9-
// _/index.js import
10-
import { buildSchema } from 'graphql/utilities';
9+
1110
// Import without explicit extension
1211
import { isPromise } from 'graphql/jsutils/isPromise';
1312

@@ -16,8 +15,6 @@ import pkg from 'graphql/package.json';
1615

1716
deepStrictEqual(version, pkg.version);
1817

19-
const schema = buildSchema('type Query { hello: String }');
20-
2118
const result = graphqlSync({
2219
schema,
2320
source: '{ hello }',
@@ -34,6 +31,6 @@ deepStrictEqual(result, {
3431
strictEqual(isPromise(Promise.resolve()), true);
3532

3633
// The possible promise rejection is handled by "--unhandled-rejections=strict"
37-
import('graphql/jsutils/isPromise').then(({ isPromise }) => {
38-
strictEqual(isPromise(Promise.resolve()), true);
34+
import('graphql/jsutils/isPromise').then((isPromisePkg) => {
35+
strictEqual(isPromisePkg.isPromise(Promise.resolve()), true);
3936
});

integrationTests/node-esm/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"graphql": "file:../graphql-esm.tgz",
99
"node-12": "npm:[email protected]",
1010
"node-14": "npm:[email protected]",
11-
"node-16": "npm:[email protected]"
11+
"node-16": "npm:[email protected]",
12+
"schema": "file:./schema",
13+
"version": "file:./version"
1214
}
1315
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "schema",
3+
"exports": {
4+
".": {
5+
"import": "./schema.mjs"
6+
}
7+
},
8+
"peerDependencies": {
9+
"graphql": "*"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { buildSchema } from 'graphql/utilities';
2+
3+
export const schema = buildSchema('type Query { hello: String }');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "bar",
3+
"type": "module",
4+
"main": "./version.js",
5+
"peerDependencies": {
6+
"graphql": "*"
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* eslint-disable import/no-unresolved, node/no-missing-import */
2+
3+
import { version } from 'graphql';
4+
5+
export { version };

0 commit comments

Comments
 (0)