Skip to content

Commit 85a8c4a

Browse files
committed
add integration tests for dev/prod
extracted from #4437
1 parent 3283f8a commit 85a8c4a

Some content is hidden

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

50 files changed

+692
-1
lines changed

cspell.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ words:
6767
# TODO: contribute upstream
6868
- deno
6969
- hashbang
70+
- Rspack
71+
- Rollup
7072

7173
# Website tech
7274
- Nextra

integrationTests/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
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 by setting the environment variable `NODE_ENV` to `development`.
20+
21+
### Verifying Production Mode Tests
22+
23+
Each subdirectory represents a different environment/bundler demonstrating production mode when development mode is not enabled.

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 mode 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 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 development mode 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 --allow-env=NODE_ENV test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}

integrationTests/dev-deno/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 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 mode should work with esbuild",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm",
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* eslint-disable import/unambiguous */
2+
/* eslint-disable import/no-commonjs */
3+
/* eslint-disable no-undef */
4+
const { isObjectType } = require('graphql');
5+
6+
class FakeGraphQLObjectType {
7+
get [Symbol.toStringTag]() {
8+
return 'GraphQLObjectType';
9+
}
10+
}
11+
12+
describe('Jest with SWC development mode tests', () => {
13+
test('isObjectType should throw in development mode for instances from another realm/module', () => {
14+
expect(() => isObjectType(new FakeGraphQLObjectType())).toThrowError(
15+
/from another module or realm/,
16+
);
17+
});
18+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const jestConfig = {
2+
testEnvironment: 'node',
3+
};
4+
5+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
6+
export default jestConfig;

0 commit comments

Comments
 (0)