Skip to content

Commit 85cc18e

Browse files
integrationTests: Add test for webpack (#3188)
Motivated by #3178
1 parent dab4f44 commit 85cc18e

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

.eslintrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ overrides:
630630
rules:
631631
node/no-sync: off
632632
node/no-missing-require: [error, { allowModules: ['graphql'] }]
633+
import/no-commonjs: off
633634
import/no-nodejs-modules: off
634635
no-console: off
635636
- files: 'benchmark/**'

integrationTests/integration-test.js

+4
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ describe('Integration Tests', () => {
4242
it('Should work on all supported node versions', () => {
4343
testOnNodeProject('node');
4444
}).timeout(40000);
45+
46+
it('Should be compatible with Webpack', () => {
47+
testOnNodeProject('webpack');
48+
}).timeout(40000);
4549
});

integrationTests/webpack/entry.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
const { buildSchema, graphqlSync } = require('graphql');
4+
5+
const schema = buildSchema('type Query { hello: String }');
6+
7+
const result = graphqlSync({
8+
schema,
9+
source: '{ hello }',
10+
rootValue: { hello: 'world' },
11+
});
12+
13+
module.exports = { result };

integrationTests/webpack/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"test": "webpack && node test.js"
5+
},
6+
"dependencies": {
7+
"graphql": "file:../graphql.tgz",
8+
"webpack": "5.x.x",
9+
"webpack-cli": "4.x.x"
10+
}
11+
}

integrationTests/webpack/test.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
5+
// eslint-disable-next-line node/no-missing-require
6+
const { result } = require('./dist/main.js');
7+
8+
assert.deepStrictEqual(result, {
9+
data: {
10+
__proto__: null,
11+
hello: 'world',
12+
},
13+
});
14+
console.log('Test script: Got correct result from Webpack bundle!');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mode": "production",
3+
"entry": "./entry.js",
4+
"output": {
5+
"libraryTarget": "commonjs2"
6+
}
7+
}

0 commit comments

Comments
 (0)