diff --git a/package.json b/package.json index 75bb3bb79..5cf11c4a8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/e2e/e2e.test.ts b/tests/e2e/e2e.test.ts index dac698bd4..7a59f0612 100644 --- a/tests/e2e/e2e.test.ts +++ b/tests/e2e/e2e.test.ts @@ -323,9 +323,15 @@ 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) => { @@ -333,6 +339,8 @@ it('When bundled custom scalars are used the project type checks and generates e }) ) + d(`starting client queries`) + const data = await testProject.client.request(gql` query { bars { @@ -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)