Skip to content

Commit c28e741

Browse files
committed
update integration tests
1 parent 7445e8e commit c28e741

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1086
-4
lines changed

cspell.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ overrides:
3939
- URQL
4040
- tada
4141
- Graphile
42-
- precompiled
42+
- precompileds
4343
- Rollup
4444
- Turbopack
4545

@@ -68,6 +68,8 @@ words:
6868
# TODO: contribute upstream
6969
- deno
7070
- hashbang
71+
- Rspack
72+
- Rsbuild
7173

7274
# Website tech
7375
- Nextra

integrationTests/README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
# TBD
1+
# Integration Tests
2+
3+
This directory contains integration tests for GraphQL.js across different environments and bundlers, testing basic GraphQL.JS functionality, as well as development mode and production mode behavior.
4+
5+
Tests are run via the main integration test suite in `resources/integration-test.ts`.
6+
7+
## Test Structure
8+
9+
### Basic GraphQL.JS Functionality Tests
10+
11+
Each subdirectory represents a different environment/bundler:
12+
13+
- `node` - tests for supported Node.js versions
14+
- `ts` - tests for supported Typescript versions
15+
- `webpack` - tests for Webpack
16+
17+
### Verifying Development Mode Tests
18+
19+
Each subdirectory represents a different environment/bundler demonstrating enabling development mode via conditional exports or by explicitly importing `graphql/dev`:
20+
21+
- `dev-bun/`: via `bun --conditions=development test.js`
22+
- `dev-deno-implicit`: via `deno run --unstable-node-conditions=development test.js`
23+
- `dev-deno-explicit`: via `import 'graphql/dev'`
24+
- `dev-node-implicit`: via `node --conditions=development test.js`
25+
- `dev-node-explicit`: via `import 'graphql/dev'`
26+
- `dev-webpack`: via `{resolve: { conditionNames: ['development'] } }`
27+
- `dev-rspack`: via `{resolve: { conditionNames: ['development'] } }`
28+
- `dev-esbuild`: via `esbuild --conditions=development test.js`
29+
- `dev-rollup`: via `@rollup/plugin-node-resolve` with `conditions: ['development']`
30+
- `dev-swc`: via `import 'graphql/dev'`
31+
- `dev-vitest`: via `resolve.conditions: ['development']`
32+
33+
### Verifying Production Mode Tests
34+
35+
Each subdirectory represents a different environment/bundler demonstrating production mode when development mode is not enabled:
36+
37+
- `prod-bun/`: via `bun test.js`
38+
- `prod-deno`: via `deno run test.js`
39+
- `prod-node`: via `node test.js`
40+
- `prod-webpack`: via default Webpack configuration
41+
- `prod-rspack`: via default Rspack configuration
42+
- `prod-esbuild`: via `esbuild test.js`
43+
- `prod-rollup`: via default Rollup configuration
44+
- `prod-swc`: via default SWC configuration
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { GraphQLSchema } = require('graphql');
4+
5+
// eslint-disable-next-line import/no-commonjs
6+
module.exports = {
7+
GraphQLSchema,
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GraphQLSchema } from 'graphql';

integrationTests/dev-bun/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "graphql-js development condition should work with Bun",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD:/usr/src/app\" -w /usr/src/app oven/bun:latest bun --conditions=development test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}

integrationTests/dev-bun/test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { isObjectType } from 'graphql';
2+
3+
import { GraphQLSchema as GraphQLSchemaFromCJS } from './cjs-module.cjs';
4+
import { GraphQLSchema as GraphQLSchemaFromESM } from './esm-module.js';
5+
6+
class GraphQLObjectType {
7+
get [Symbol.toStringTag]() {
8+
return 'GraphQLObjectType';
9+
}
10+
}
11+
12+
try {
13+
isObjectType(new GraphQLObjectType());
14+
throw new Error(
15+
'Expected isObjectType to throw an error in Bun development mode.',
16+
);
17+
} catch (error) {
18+
if (!error.message.includes('from another module or realm')) {
19+
throw error;
20+
}
21+
}
22+
23+
if (GraphQLSchemaFromCJS !== GraphQLSchemaFromESM) {
24+
throw new Error(
25+
'Dual package hazard detected: GraphQLSchema instances from CJS and ESM imports are not identical.',
26+
);
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { GraphQLSchema } = require('graphql');
4+
5+
// eslint-disable-next-line import/no-commonjs
6+
module.exports = {
7+
GraphQLSchema,
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GraphQLSchema } from 'graphql';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "graphql-js explicit development import should work with Deno",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD:/usr/src/app\" -w /usr/src/app denoland/deno:latest deno run test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// eslint-disable-next-line import/no-unassigned-import, simple-import-sort/imports
2+
import 'graphql/dev';
3+
import { isObjectType } from 'graphql';
4+
5+
import { GraphQLSchema as GraphQLSchemaFromCJS } from './cjs-module.cjs';
6+
import { GraphQLSchema as GraphQLSchemaFromESM } from './esm-module.js';
7+
8+
class GraphQLObjectType {
9+
get [Symbol.toStringTag]() {
10+
return 'GraphQLObjectType';
11+
}
12+
}
13+
14+
try {
15+
isObjectType(new GraphQLObjectType());
16+
throw new Error(
17+
'Expected isObjectType to throw an error in Deno explicit dev import mode.',
18+
);
19+
} catch (error) {
20+
if (!error.message.includes('from another module or realm')) {
21+
throw error;
22+
}
23+
}
24+
25+
if (GraphQLSchemaFromCJS !== GraphQLSchemaFromESM) {
26+
throw new Error(
27+
'Dual package hazard detected: GraphQLSchema instances from CJS and ESM imports are not identical.',
28+
);
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { GraphQLSchema } = require('graphql');
4+
5+
// eslint-disable-next-line import/no-commonjs
6+
module.exports = {
7+
GraphQLSchema,
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GraphQLSchema } from 'graphql';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "graphql-js development condition should work with Deno",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD:/usr/src/app\" -w /usr/src/app denoland/deno:latest deno run --unstable-node-conditions=development test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { isObjectType } from 'graphql';
2+
3+
import { GraphQLSchema as GraphQLSchemaFromCJS } from './cjs-module.cjs';
4+
import { GraphQLSchema as GraphQLSchemaFromESM } from './esm-module.js';
5+
6+
class GraphQLObjectType {
7+
get [Symbol.toStringTag]() {
8+
return 'GraphQLObjectType';
9+
}
10+
}
11+
12+
try {
13+
isObjectType(new GraphQLObjectType());
14+
throw new Error(
15+
'Expected isObjectType to throw an error in Deno implicit dev mode.',
16+
);
17+
} catch (error) {
18+
if (!error.message.includes('from another module or realm')) {
19+
throw error;
20+
}
21+
}
22+
23+
if (GraphQLSchemaFromCJS !== GraphQLSchemaFromESM) {
24+
throw new Error(
25+
'Dual package hazard detected: GraphQLSchema instances from CJS and ESM imports are not identical.',
26+
);
27+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"description": "graphql-js development condition should work with esbuild",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "esbuild src/index.js --bundle --outfile=dist/bundle.js --format=esm --conditions=development,module",
7+
"test": "npm run build && node dist/bundle.js"
8+
},
9+
"dependencies": {
10+
"graphql": "file:../graphql.tgz",
11+
"esbuild": "^0.25.0"
12+
}
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { GraphQLSchema } = require('graphql');
4+
5+
// eslint-disable-next-line import/no-commonjs
6+
module.exports = {
7+
GraphQLSchema,
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GraphQLSchema } from 'graphql';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { isObjectType } from 'graphql';
2+
3+
import { GraphQLSchema as GraphQLSchemaFromCJS } from './cjs-module.cjs';
4+
import { GraphQLSchema as GraphQLSchemaFromESM } from './esm-module.js';
5+
6+
class GraphQLObjectType {
7+
get [Symbol.toStringTag]() {
8+
return 'GraphQLObjectType';
9+
}
10+
}
11+
12+
try {
13+
isObjectType(new GraphQLObjectType());
14+
throw new Error(
15+
'Expected isObjectType to throw an error in esbuild development mode.',
16+
);
17+
} catch (error) {
18+
if (!error.message.includes('from another module or realm')) {
19+
throw error;
20+
}
21+
}
22+
23+
if (GraphQLSchemaFromCJS !== GraphQLSchemaFromESM) {
24+
throw new Error(
25+
'Dual package hazard detected: GraphQLSchema instances from CJS and ESM imports are not identical.',
26+
);
27+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* eslint-disable import/no-unassigned-import */
2+
import 'graphql/dev';
3+
import './test.js';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { GraphQLSchema } = require('graphql');
4+
5+
// eslint-disable-next-line import/no-commonjs
6+
module.exports = {
7+
GraphQLSchema,
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GraphQLSchema } from 'graphql';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"description": "explicit graphql-js development mode should work with node",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"test": "node bootstrap.js"
7+
},
8+
"dependencies": {
9+
"graphql": "file:../graphql.tgz"
10+
}
11+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { isObjectType } from 'graphql';
2+
3+
import { GraphQLSchema as GraphQLSchemaFromCJS } from './cjs-module.cjs';
4+
import { GraphQLSchema as GraphQLSchemaFromESM } from './esm-module.js';
5+
6+
class GraphQLObjectType {
7+
get [Symbol.toStringTag]() {
8+
return 'GraphQLObjectType';
9+
}
10+
}
11+
12+
try {
13+
isObjectType(new GraphQLObjectType());
14+
throw new Error(
15+
'Expected isObjectType to throw an error in Node.js explicit dev import mode.',
16+
);
17+
} catch (error) {
18+
if (!error.message.includes('from another module or realm')) {
19+
throw error;
20+
}
21+
}
22+
23+
if (GraphQLSchemaFromCJS !== GraphQLSchemaFromESM) {
24+
throw new Error(
25+
'Dual package hazard detected: GraphQLSchema instances from CJS and ESM imports are not identical.',
26+
);
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { GraphQLSchema } = require('graphql');
4+
5+
// eslint-disable-next-line import/no-commonjs
6+
module.exports = {
7+
GraphQLSchema,
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GraphQLSchema } from 'graphql';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"description": "graphql-js development condition should work with node",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"test": "node --conditions=development test.js"
7+
},
8+
"dependencies": {
9+
"graphql": "file:../graphql.tgz"
10+
}
11+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { isObjectType } from 'graphql';
2+
3+
import { GraphQLSchema as GraphQLSchemaFromCJS } from './cjs-module.cjs';
4+
import { GraphQLSchema as GraphQLSchemaFromESM } from './esm-module.js';
5+
6+
class GraphQLObjectType {
7+
get [Symbol.toStringTag]() {
8+
return 'GraphQLObjectType';
9+
}
10+
}
11+
12+
try {
13+
isObjectType(new GraphQLObjectType());
14+
throw new Error(
15+
'Expected isObjectType to throw an error in Node.js implicit dev mode.',
16+
);
17+
} catch (error) {
18+
if (!error.message.includes('from another module or realm')) {
19+
throw error;
20+
}
21+
}
22+
23+
if (GraphQLSchemaFromCJS !== GraphQLSchemaFromESM) {
24+
throw new Error(
25+
'Dual package hazard detected: GraphQLSchema instances from CJS and ESM imports are not identical.',
26+
);
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"description": "graphql-js development condition should work with Rollup",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "rollup -c",
7+
"test": "npm run build && node dist/bundle.js"
8+
},
9+
"dependencies": {
10+
"graphql": "file:../graphql.tgz",
11+
"rollup": "^4.0.0",
12+
"@rollup/plugin-node-resolve": "^15.0.0"
13+
}
14+
}

0 commit comments

Comments
 (0)