Skip to content

Commit e4c328a

Browse files
committed
new integration tests
1 parent bdf3a8f commit e4c328a

Some content is hidden

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

53 files changed

+972
-1
lines changed

integrationTests/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
# TBD
1+
# Integration Tests
2+
3+
This directory contains integration tests for GraphQL.js across different environments and bundlers, testing both development mode and production mode functionality.
4+
5+
## Test Structure
6+
7+
Each subdirectory represents a different environment/bundler:
8+
9+
- `node/` - Node.js runtime tests
10+
- `deno/` - Deno runtime tests
11+
- `bun/` - Bun runtime tests
12+
- `webpack/` - Webpack bundler tests
13+
- `rollup/` - Rollup bundler tests
14+
- `esbuild/` - esbuild bundler tests
15+
- `vite/` - Vite bundler tests
16+
- `nextjs/` - Next.js framework tests
17+
- `create-react-app/` - Create React App tests
18+
- `swc/` - SWC bundler tests
19+
20+
## Development Mode Testing
21+
22+
Each test verifies:
23+
1. Development mode is properly enabled (explicit import or conditional exports)
24+
2. Production mode works without development overhead
25+
3. Multiple GraphQL.js module detection works in development
26+
4. Performance characteristics differ between modes
27+
28+
## Running Tests
29+
30+
Tests are run via the main integration test suite in `resources/integration-test.ts`.

integrationTests/dev-bun/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "graphql-js-test-dev-bun",
3+
"description": "Bun development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"scripts": {
7+
"test": "bun --conditions=development test.js"
8+
},
9+
"dependencies": {
10+
"graphql": "file:../graphql.tgz"
11+
}
12+
}

integrationTests/dev-bun/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ Bun development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "graphql-js-test-dev-deno",
3+
"description": "Deno development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"scripts": {
7+
"test": "deno run --unstable-node-conditions=development test.js"
8+
},
9+
"dependencies": {
10+
"graphql": "file:../graphql.tgz"
11+
}
12+
}

integrationTests/dev-deno/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ Deno development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "graphql-js-test-dev-esbuild",
3+
"description": "esbuild development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"build": "esbuild src/index.js --bundle --outfile=dist/bundle.js --format=esm --conditions=development,module",
9+
"test": "npm run build && node dist/bundle.js"
10+
},
11+
"dependencies": {
12+
"graphql": "file:../graphql.tgz"
13+
},
14+
"devDependencies": {
15+
"esbuild": "^0.20.0"
16+
}
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ esbuild development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Next.js doesn't support conditional exports in all configurations, so we use explicit development mode
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+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
experimental: {
4+
esmExternals: true
5+
}
6+
};
7+
8+
module.exports = nextConfig;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "graphql-js-test-dev-nextjs",
3+
"description": "Next.js development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"scripts": {
7+
"build": "next build",
8+
"test": "npm run build && node bootstrap.js"
9+
},
10+
"dependencies": {
11+
"graphql": "file:../graphql.tgz",
12+
"next": "^14.0.0",
13+
"react": "^18.0.0",
14+
"react-dom": "^18.0.0"
15+
}
16+
}

integrationTests/dev-nextjs/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ Next.js development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Explicit development mode enabling
2+
import 'graphql/dev';
3+
import './test.js';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "graphql-js-test-dev-node-explicit",
3+
"description": "Node.js explicit development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"test": "node bootstrap.js"
9+
},
10+
"dependencies": {
11+
"graphql": "file:../graphql.tgz"
12+
}
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ Node.js explicit development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "graphql-js-test-dev-node",
3+
"description": "Node.js development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"test": "node --conditions=development test.js"
9+
},
10+
"dependencies": {
11+
"graphql": "file:../graphql.tgz"
12+
}
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ Node.js development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "graphql-js-test-dev-rollup",
3+
"description": "Rollup development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"build": "rollup -c",
9+
"test": "npm run build && node dist/bundle.js"
10+
},
11+
"dependencies": {
12+
"graphql": "file:../graphql.tgz"
13+
},
14+
"devDependencies": {
15+
"rollup": "^4.0.0",
16+
"@rollup/plugin-node-resolve": "^15.0.0"
17+
}
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import resolve from '@rollup/plugin-node-resolve';
2+
3+
export default {
4+
input: 'src/index.js',
5+
output: {
6+
file: 'dist/bundle.js',
7+
format: 'es'
8+
},
9+
plugins: [
10+
resolve({
11+
exportConditions: ['development']
12+
})
13+
]
14+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isObjectType } from 'graphql';
2+
3+
// Create a fake GraphQLObjectType to test instanceof behavior
4+
class FakeGraphQLObjectType {
5+
constructor() {
6+
this.name = 'Fake';
7+
}
8+
}
9+
10+
const fakeInstance = new FakeGraphQLObjectType();
11+
12+
try {
13+
const result = isObjectType(fakeInstance);
14+
15+
// In development mode, this should throw an error about multiple GraphQL modules
16+
// If we get here without an error, development mode is not working
17+
console.error('✗ Development mode test failed - expected error was not thrown');
18+
process.exit(1);
19+
} catch (error) {
20+
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21+
console.log('✓ Rollup development mode integration test passed');
22+
} else {
23+
console.error('✗ Development mode test failed - unexpected error:', error.message);
24+
process.exit(1);
25+
}
26+
}

integrationTests/dev-swc/.swcrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"jsc": {
3+
"parser": {
4+
"syntax": "ecmascript",
5+
"jsx": false
6+
},
7+
"target": "es2020"
8+
},
9+
"module": {
10+
"type": "es6"
11+
}
12+
}

integrationTests/dev-swc/bootstrap.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// SWC doesn't support conditional exports, so we use explicit development mode
2+
import 'graphql/dev';
3+
import './dist/index.js';

integrationTests/dev-swc/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "graphql-js-test-dev-swc",
3+
"description": "SWC development mode integration test",
4+
"version": "1.0.0",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"build": "swc src -d dist",
9+
"test": "npm run build && node bootstrap.js"
10+
},
11+
"dependencies": {
12+
"graphql": "file:../graphql.tgz"
13+
},
14+
"devDependencies": {
15+
"@swc/cli": "^0.1.0",
16+
"@swc/core": "^1.3.0"
17+
}
18+
}

0 commit comments

Comments
 (0)