Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrationTests: Add test for webpack #3188

Merged
merged 1 commit into from Jun 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
}
}