forked from graphql/express-graphql
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrationTests: test built package on all supported node versions
Motivated by graphql#665
- Loading branch information
1 parent
f894ae8
commit 949df51
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
const { buildSchema } = require('graphql'); | ||
|
||
const { graphqlHTTP } = require('express-graphql'); | ||
|
||
const schema = buildSchema('type Query { hello: String }'); | ||
|
||
const middleware = graphqlHTTP({ | ||
graphiql: true, | ||
schema, | ||
rootValue: { hello: 'world' }, | ||
}); | ||
|
||
assert(typeof middleware === 'function'); | ||
|
||
const request = { | ||
url: 'http://example.com', | ||
method: 'GET', | ||
headers: {}, | ||
body: { | ||
query: '{ hello }', | ||
}, | ||
}; | ||
|
||
const response = { | ||
headers: {}, | ||
setHeader(name, value) { | ||
this.headers[name] = value; | ||
}, | ||
text: null, | ||
end(buffer) { | ||
this.text = buffer.toString(); | ||
}, | ||
}; | ||
|
||
middleware(request, response).then(() => { | ||
assert.deepStrictEqual(response.headers, { | ||
'Content-Length': '26', | ||
'Content-Type': 'application/json; charset=utf-8', | ||
}); | ||
assert.deepStrictEqual(response.text, '{"data":{"hello":"world"}}'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"dependencies": { | ||
"express-graphql": "file:../express-graphql.tgz", | ||
"graphql": "14.7.0", | ||
"node-10": "npm:node@10.x.x", | ||
"node-12": "npm:node@12.x.x", | ||
"node-14": "npm:node@14.x.x" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const childProcess = require('child_process'); | ||
|
||
const { dependencies } = require('./package.json'); | ||
|
||
const nodeVersions = Object.keys(dependencies) | ||
.filter((pkg) => pkg.startsWith('node-')) | ||
.sort((a, b) => b.localeCompare(a)); | ||
|
||
for (const version of nodeVersions) { | ||
console.log(`Testing on ${version} ...`); | ||
|
||
const nodePath = path.join(__dirname, 'node_modules', version, 'bin/node'); | ||
childProcess.execSync(nodePath + ' index.js', { stdio: 'inherit' }); | ||
} |