Skip to content

Commit 38992e3

Browse files
committed
update integration tests
1 parent 7445e8e commit 38992e3

Some content is hidden

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

56 files changed

+801
-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: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,45 @@
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+
- `dev-jest`: via `testEnvironmentOptions.customExportConditions: ['development']` and `@swc/jest` transform
33+
34+
### Verifying Production Mode Tests
35+
36+
Each subdirectory represents a different environment/bundler demonstrating production mode when development mode is not enabled:
37+
38+
- `prod-bun/`: via `bun test.js`
39+
- `prod-deno`: via `deno run test.js`
40+
- `prod-node`: via `node test.js`
41+
- `prod-webpack`: via default Webpack configuration
42+
- `prod-rspack`: via default Rspack configuration
43+
- `prod-esbuild`: via `esbuild test.js`
44+
- `prod-rollup`: via default Rollup configuration
45+
- `prod-swc`: via default SWC configuration

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Bun development mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// eslint-disable-next-line import/no-unassigned-import, simple-import-sort/imports
2+
import 'graphql/dev';
3+
import { isObjectType } from 'graphql';
4+
5+
class GraphQLObjectType {
6+
get [Symbol.toStringTag]() {
7+
return 'GraphQLObjectType';
8+
}
9+
}
10+
11+
try {
12+
isObjectType(new GraphQLObjectType());
13+
throw new Error(
14+
'Expected isObjectType to throw an error in Deno explicit dev import mode.',
15+
);
16+
} catch (error) {
17+
if (!error.message.includes('from another module or realm')) {
18+
throw error;
19+
}
20+
}
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Deno implicit dev mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}

integrationTests/dev-esbuild/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in esbuild development mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
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 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable no-undef */
2+
import { isObjectType } from 'graphql';
3+
4+
class FakeGraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
7+
}
8+
}
9+
10+
describe('Jest with SWC development mode tests', () => {
11+
test('isObjectType should throw in development mode for instances from another realm/module', () => {
12+
expect(() => isObjectType(new FakeGraphQLObjectType())).toThrowError(
13+
/from another module or realm/,
14+
);
15+
});
16+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const jestConfig = {
2+
testEnvironment: 'node',
3+
4+
testEnvironmentOptions: {
5+
customExportConditions: ['development', 'node'],
6+
},
7+
8+
transform: {
9+
'^.+\\.(t|j)sx?$': ['@swc/jest'],
10+
},
11+
12+
transformIgnorePatterns: [
13+
// Allow 'graphql' to be transformed, ignore all other node_modules.
14+
// This regex means: "match /node_modules/ unless it's followed by graphql/"
15+
'/node_modules/(?!graphql/)',
16+
// Keep Jest's default for .pnp.js files if using Yarn PnP
17+
'\\.pnp\\.[^\\/]+$',
18+
],
19+
};
20+
21+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
22+
export default jestConfig;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"description": "graphql-js development condition should work with Jest and SWC",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"test": "jest"
7+
},
8+
"dependencies": {
9+
"graphql": "file:../graphql.tgz"
10+
},
11+
"devDependencies": {
12+
"jest": "^29.7.0",
13+
"@swc/core": "^1.6.0",
14+
"@swc/jest": "^0.2.36"
15+
}
16+
}
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: 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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Node.js explicit dev import mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Node.js implicit dev mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}

integrationTests/dev-rollup/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Rollup development mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
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+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// eslint-disable-next-line n/no-missing-import
2+
import resolve from '@rollup/plugin-node-resolve';
3+
4+
const rollupConfig = {
5+
input: 'index.js',
6+
output: {
7+
file: 'dist/bundle.js',
8+
format: 'es',
9+
},
10+
plugins: [
11+
resolve({
12+
exportConditions: ['development'],
13+
}),
14+
],
15+
};
16+
17+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
18+
export default rollupConfig;

integrationTests/dev-rspack/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Rspack development mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"description": "graphql-js development condition should work with Rspack",
3+
"private": true,
4+
"scripts": {
5+
"test": "rspack --mode=development && node dist/main.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz",
9+
"@rspack/core": "^1.0.0",
10+
"@rspack/cli": "^1.0.0"
11+
}
12+
}

0 commit comments

Comments
 (0)