Skip to content

Commit 1f11606

Browse files
committed
test: Add dev-vitest integration test
1 parent 4f20e46 commit 1f11606

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

integrationTests/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ Each subdirectory represents a different environment/bundler:
1414
- `ts` - tests for supported Typescript versions
1515
- `webpack` - tests for Webpack
1616

17-
### Dual Package Hazard Tests
18-
19-
- `dual-vitest` - ensure that vitest loads only a single package.
20-
2117
### Verifying Development Mode Tests
2218

2319
Each subdirectory represents a different environment/bundler demonstrating enabling development mode via conditional exports or by explicitly importing `graphql/dev`:
@@ -32,6 +28,7 @@ Each subdirectory represents a different environment/bundler demonstrating enabl
3228
- `dev-esbuild`: via `esbuild --conditions=development test.js`
3329
- `dev-rollup`: via `@rollup/plugin-node-resolve` with `conditions: ['development']`
3430
- `dev-swc`: via `import 'graphql/dev'`
31+
- `dev-vitest`: via `resolve.conditions: ['development']`
3532

3633
### Verifying Production Mode Tests
3734

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { isObjectType } from 'graphql';
2+
// eslint-disable-next-line n/no-missing-import
3+
import { expect, test } from 'vitest';
4+
5+
class GraphQLObjectTypeMimic {
6+
get [Symbol.toStringTag]() {
7+
return 'GraphQLObjectType';
8+
}
9+
}
10+
11+
test('isObjectType should throw in development mode for instances from another realm/module', () => {
12+
expect(() => isObjectType(new GraphQLObjectTypeMimic())).toThrowError(
13+
/from another module or realm/,
14+
);
15+
});
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 Vitest",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"test": "vitest run"
7+
},
8+
"dependencies": {
9+
"graphql": "file:../graphql.tgz",
10+
"vitest": "^1.0.0"
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// eslint-disable-next-line n/no-missing-import
2+
import { defineConfig } from 'vitest/config';
3+
4+
const vitestConfig = defineConfig({
5+
resolve: {
6+
conditions: ['development'],
7+
},
8+
test: {
9+
include: ['**/*.test.js'],
10+
},
11+
});
12+
13+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
14+
export default vitestConfig;

resources/integration-test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Integration Tests', () => {
1616
const archiveName = npm({ cwd: tmpDirPath(), quiet: true }).pack(distDir);
1717
fs.renameSync(tmpDirPath(archiveName), tmpDirPath('graphql.tgz'));
1818

19-
// npm().run('build:deno');
19+
npm().run('build:deno');
2020

2121
function testOnNodeProject(projectName: string) {
2222
const projectPath = tmpDirPath(projectName);
@@ -29,9 +29,6 @@ describe('Integration Tests', () => {
2929
}).timeout(120000);
3030
}
3131

32-
testOnNodeProject('dual-vitest');
33-
return;
34-
3532
testOnNodeProject('ts');
3633
testOnNodeProject('node');
3734
testOnNodeProject('webpack');
@@ -47,13 +44,14 @@ describe('Integration Tests', () => {
4744
testOnNodeProject('dev-rollup');
4845
testOnNodeProject('dev-esbuild');
4946
testOnNodeProject('dev-swc');
47+
testOnNodeProject('dev-vitest');
5048

5149
// Production mode tests
5250
testOnNodeProject('prod-node');
5351
testOnNodeProject('prod-deno');
5452
testOnNodeProject('prod-bun');
5553
testOnNodeProject('prod-webpack');
56-
testOnNodeProject('dev-rspack');
54+
testOnNodeProject('prod-rspack');
5755
testOnNodeProject('prod-rollup');
5856
testOnNodeProject('prod-esbuild');
5957
testOnNodeProject('prod-swc');

0 commit comments

Comments
 (0)