Skip to content

Commit 771e7a4

Browse files
committed
demonstrate changes to get dual-build graphql-js working with jest
- use jest config setting: testEnvironment / customExportConditions - use latest dev mode with dual build (see graphql/graphql-js#4464) - no need for additional transformer
1 parent 9a60182 commit 771e7a4

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

graphql-17.0.0-alpha.9.tgz

790 KB
Binary file not shown.

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"graphql": "16.11.0",
6868
"graphql-subscriptions": "3.0.0",
6969
"graphql-tag": "2.12.6",
70+
"graphql17": "file:graphql-17.0.0-alpha.9.tgz",
7071
"jest": "30.0.5",
7172
"jest-config": "30.0.5",
7273
"jest-junit": "16.0.0",

packages/server/jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ import baseConfig from '../../jest.config.base.js';
22

33
// This needs to be "cloned" since jest depends on the object's identity in some
44
// way, whether it's via mutation or something else.
5-
export default { ...baseConfig };
5+
export default {
6+
...baseConfig,
7+
testEnvironmentOptions: {
8+
customExportConditions: ['node', 'development'],
9+
},
10+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { describe, it, expect } from '@jest/globals';
2+
import { GraphQLObjectType, isObjectType, version } from 'graphql17';
3+
4+
describe('canary graphql v17-alpha', () => {
5+
it('should work', () => {
6+
expect(version).toBe('17.0.0-alpha.9'); // this version is the latest alpha on which the canary is based
7+
});
8+
9+
it('should use development mode when set by our Jest Config', () => {
10+
function getFakeGraphQLObjectType() {
11+
class GraphQLObjectType {
12+
get [Symbol.toStringTag]() {
13+
return 'GraphQLObjectType';
14+
}
15+
}
16+
return new GraphQLObjectType();
17+
}
18+
19+
expect(isObjectType(new GraphQLObjectType({ name: 'SomeType', fields: {} }))).toBe(true);
20+
expect(() => isObjectType(getFakeGraphQLObjectType())).toThrow();
21+
});
22+
});

0 commit comments

Comments
 (0)