-
-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add apollo-server-lambda scenario test
- Loading branch information
1 parent
eb92c45
commit e275fc8
Showing
9 changed files
with
1,077 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
const { resolve } = require('path') | ||
const execa = require('execa') | ||
|
||
// setup.js | ||
module.exports = async () => { | ||
return execa('npm', ['ci'], { | ||
cwd: resolve(__dirname, '../scenario/apollo-server-lambda'), | ||
stdio: 'inherit', | ||
}) | ||
} |
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,7 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
rules: { | ||
'import/no-unresolved': 'off', | ||
}, | ||
} |
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,51 @@ | ||
'use strict' | ||
|
||
const { resolve } = require('path') | ||
const { default: ApolloClient } = require('apollo-boost') | ||
const gql = require('graphql-tag') | ||
const { | ||
joinUrl, | ||
setup, | ||
teardown, | ||
} = require('../../integration/_testHelpers/index.js') | ||
|
||
jest.setTimeout(30000) | ||
|
||
describe('apollo server lambda graphql', () => { | ||
// init | ||
beforeAll(() => | ||
setup({ | ||
servicePath: resolve(__dirname), | ||
}), | ||
) | ||
|
||
// cleanup | ||
afterAll(() => teardown()) | ||
|
||
test('apollo server lambda tests', async () => { | ||
const url = joinUrl(TEST_BASE_URL, '/graphql') | ||
|
||
const apolloClient = new ApolloClient({ | ||
uri: url.toString(), | ||
}) | ||
|
||
const data = await apolloClient.query({ | ||
query: gql` | ||
query test { | ||
hello | ||
} | ||
`, | ||
}) | ||
|
||
const expected = { | ||
data: { | ||
hello: 'Hello world!', | ||
}, | ||
loading: false, | ||
networkStatus: 7, | ||
stale: false, | ||
} | ||
|
||
expect(data).toEqual(expected) | ||
}) | ||
}) |
Oops, something went wrong.