Skip to content

Commit

Permalink
expand node-esm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Nov 10, 2021
1 parent 89a7efc commit 1f2d271
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ rules:

overrides:
- files:
- 'integrationTests/webpack-esm/*.js'
- 'integrationTests/node-esm/*.js'
- 'integrationTests/node-esm/**/*.js'
parserOptions:
sourceType: module
- files: '**/*.ts'
Expand Down
17 changes: 7 additions & 10 deletions integrationTests/node-esm/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* eslint-disable node/no-missing-import, import/no-unresolved */
/* eslint-disable node/no-missing-import, import/no-unresolved, node/no-unsupported-features/es-syntax */

import { deepStrictEqual, strictEqual } from 'assert';

// Regular import
import { version } from 'version';
import { schema } from 'schema';

import { graphqlSync } from 'graphql';
// Import with explicit extension
import { version } from 'graphql/version.js';
// _/index.js import
import { buildSchema } from 'graphql/utilities';

// Import without explicit extension
import { isPromise } from 'graphql/jsutils/isPromise';

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

deepStrictEqual(version, pkg.version);

const schema = buildSchema('type Query { hello: String }');

const result = graphqlSync({
schema,
source: '{ hello }',
Expand All @@ -34,6 +31,6 @@ deepStrictEqual(result, {
strictEqual(isPromise(Promise.resolve()), true);

// The possible promise rejection is handled by "--unhandled-rejections=strict"
import('graphql/jsutils/isPromise').then(({ isPromise }) => {
strictEqual(isPromise(Promise.resolve()), true);
import('graphql/jsutils/isPromise').then((isPromisePkg) => {
strictEqual(isPromisePkg.isPromise(Promise.resolve()), true);
});
4 changes: 3 additions & 1 deletion integrationTests/node-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"graphql": "file:../graphql-esm.tgz",
"node-12": "npm:[email protected]",
"node-14": "npm:[email protected]",
"node-16": "npm:[email protected]"
"node-16": "npm:[email protected]",
"schema": "file:./schema",
"version": "file:./version"
}
}
11 changes: 11 additions & 0 deletions integrationTests/node-esm/schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "schema",
"exports": {
".": {
"import": "./schema.mjs"
}
},
"peerDependencies": {
"graphql": "*"
}
}
3 changes: 3 additions & 0 deletions integrationTests/node-esm/schema/schema.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { buildSchema } from 'graphql/utilities';

export const schema = buildSchema('type Query { hello: String }');
8 changes: 8 additions & 0 deletions integrationTests/node-esm/version/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "bar",
"type": "module",
"main": "./version.js",
"peerDependencies": {
"graphql": "*"
}
}
5 changes: 5 additions & 0 deletions integrationTests/node-esm/version/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable import/no-unresolved, node/no-missing-import */

import { version } from 'graphql';

export { version };

0 comments on commit 1f2d271

Please sign in to comment.