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

tests(e2e): fix windows #31

Merged
merged 4 commits into from
May 11, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"dev:yalc": "nodemon --exec 'yalc push --no-scripts' --watch 'dist/**/*'",
"build:module-facades": "ts-node scripts/build-module-facades",
"build": "yarn clean && yarn build:module-facades && tsc",
"test": "jest",
"test:ci": "jest --coverage --forceExit",
"test": "cross-env DEBUG=e2e jest",
"test:ci": "cross-env DEBUG=e2e jest --coverage --forceExit",
"tdd": "jest --watch",
"tdd:e2e:debug": "cross-env test_project_reuse=true jest --watch e2e",
"clean": "rm -rf dist && rm -rf node_modules/.cache",
Expand Down
18 changes: 16 additions & 2 deletions tests/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,24 @@ it('When bundled custom scalars are used the project type checks and generates e
/**
* Sanity check the runtime
*/

d(`migrating database`)

testProject.runOrThrow(`npm run db:migrate`)

d(`starting server`)

const serverProcess = testProject.runAsync(`node build/server`, { reject: false })
serverProcess.stdout!.pipe(process.stdout)

await new Promise((res) =>
serverProcess.stdout!.on('data', (data: Buffer) => {
if (data.toString().match(SERVER_READY_MESSAGE)) res(undefined)
})
)

d(`starting client queries`)

const data = await testProject.client.request(gql`
query {
bars {
Expand All @@ -346,8 +354,14 @@ it('When bundled custom scalars are used the project type checks and generates e
}
`)

expect(data).toMatchSnapshot('client request 1')
d(`stopping server`)

serverProcess.cancel()
await serverProcess
// On Windows the serverProcess never completes the promise so we do an ugly timeout here
// and rely on jest --forceExit to terminate the process
await Promise.race([serverProcess, new Promise((res) => setTimeout(res, 2000))])

d(`stopped server`)

expect(data).toMatchSnapshot('client request 1')
}, 30_000)