Skip to content

Commit

Permalink
Add apollo-server-lambda scenario test
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Aug 24, 2019
1 parent eb92c45 commit e275fc8
Show file tree
Hide file tree
Showing 9 changed files with 1,077 additions and 1 deletion.
12 changes: 12 additions & 0 deletions __tests__/_setupTeardown/npmInstall.js
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',
})
}
7 changes: 7 additions & 0 deletions __tests__/scenario/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

module.exports = {
rules: {
'import/no-unresolved': 'off',
},
}
51 changes: 51 additions & 0 deletions __tests__/scenario/apollo-server-lambda/apollo.test.js
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)
})
})
Loading

0 comments on commit e275fc8

Please sign in to comment.