Skip to content

Commit

Permalink
integrationTests: Add test for webpack (#3188)
Browse files Browse the repository at this point in the history
Motivated by #3178
  • Loading branch information
IvanGoncharov committed Jun 20, 2021
1 parent dab4f44 commit 85cc18e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Expand Up @@ -630,6 +630,7 @@ overrides:
rules:
node/no-sync: off
node/no-missing-require: [error, { allowModules: ['graphql'] }]
import/no-commonjs: off
import/no-nodejs-modules: off
no-console: off
- files: 'benchmark/**'
Expand Down
4 changes: 4 additions & 0 deletions integrationTests/integration-test.js
Expand Up @@ -42,4 +42,8 @@ describe('Integration Tests', () => {
it('Should work on all supported node versions', () => {
testOnNodeProject('node');
}).timeout(40000);

it('Should be compatible with Webpack', () => {
testOnNodeProject('webpack');
}).timeout(40000);
});
13 changes: 13 additions & 0 deletions integrationTests/webpack/entry.js
@@ -0,0 +1,13 @@
'use strict';

const { buildSchema, graphqlSync } = require('graphql');

const schema = buildSchema('type Query { hello: String }');

const result = graphqlSync({
schema,
source: '{ hello }',
rootValue: { hello: 'world' },
});

module.exports = { result };
11 changes: 11 additions & 0 deletions integrationTests/webpack/package.json
@@ -0,0 +1,11 @@
{
"private": true,
"scripts": {
"test": "webpack && node test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz",
"webpack": "5.x.x",
"webpack-cli": "4.x.x"
}
}
14 changes: 14 additions & 0 deletions integrationTests/webpack/test.js
@@ -0,0 +1,14 @@
'use strict';

const assert = require('assert');

// eslint-disable-next-line node/no-missing-require
const { result } = require('./dist/main.js');

assert.deepStrictEqual(result, {
data: {
__proto__: null,
hello: 'world',
},
});
console.log('Test script: Got correct result from Webpack bundle!');
7 changes: 7 additions & 0 deletions integrationTests/webpack/webpack.config.json
@@ -0,0 +1,7 @@
{
"mode": "production",
"entry": "./entry.js",
"output": {
"libraryTarget": "commonjs2"
}
}

0 comments on commit 85cc18e

Please sign in to comment.