From fb46a3319f1eabc92012a313c35ce7f1ecfa31ca Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 28 Apr 2021 18:50:44 +0200 Subject: [PATCH] test: fix timeout hiding runtime build error (#3185) --- packages/playground/ssr-react/__tests__/serve.js | 4 ++-- packages/playground/ssr-vue/__tests__/serve.js | 4 ++-- packages/plugin-legacy/index.js | 2 +- scripts/jestPerTestSetup.ts | 8 +++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/playground/ssr-react/__tests__/serve.js b/packages/playground/ssr-react/__tests__/serve.js index 7c7b1867ae53f6..1bc028c03dc27c 100644 --- a/packages/playground/ssr-react/__tests__/serve.js +++ b/packages/playground/ssr-react/__tests__/serve.js @@ -17,7 +17,7 @@ exports.serve = async function serve(root, isProd) { // client build await build({ root, - logLevel: 'error', + logLevel: 'silent', // exceptions are logged by Jest build: { target: 'esnext', minify: false, @@ -28,7 +28,7 @@ exports.serve = async function serve(root, isProd) { // server build await build({ root, - logLevel: 'error', + logLevel: 'silent', build: { target: 'esnext', ssr: 'src/entry-server.jsx', diff --git a/packages/playground/ssr-vue/__tests__/serve.js b/packages/playground/ssr-vue/__tests__/serve.js index c0bca625106e4e..1e220fed9630e4 100644 --- a/packages/playground/ssr-vue/__tests__/serve.js +++ b/packages/playground/ssr-vue/__tests__/serve.js @@ -17,7 +17,7 @@ exports.serve = async function serve(root, isProd) { // client build await build({ root, - logLevel: 'error', + logLevel: 'silent', // exceptions are logged by Jest build: { target: 'esnext', minify: false, @@ -28,7 +28,7 @@ exports.serve = async function serve(root, isProd) { // server build await build({ root, - logLevel: 'error', + logLevel: 'silent', build: { target: 'esnext', ssr: 'src/entry-server.js', diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 60dee775aaa5d2..532f63ec2577a8 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -458,7 +458,7 @@ async function buildPolyfillChunk( // so that everything is resolved from here root: __dirname, configFile: false, - logLevel: 'error', + logLevel: 'silent', // exceptions are logged by Jest plugins: [polyfillsPlugin(imports)], build: { write: false, diff --git a/scripts/jestPerTestSetup.ts b/scripts/jestPerTestSetup.ts index 08e4fb56dc3dad..9b53793a36d384 100644 --- a/scripts/jestPerTestSetup.ts +++ b/scripts/jestPerTestSetup.ts @@ -66,7 +66,7 @@ beforeAll(async () => { const options: UserConfig = { root: tempDir, - logLevel: 'error', + logLevel: 'silent', server: { watch: { // During tests we edit the files too fast and sometimes chokidar @@ -100,6 +100,12 @@ beforeAll(async () => { // jest doesn't exit if our setup has error here // https://github.com/facebook/jest/issues/2713 err = e + + // Closing the page since an error in the setup, for example a runtime error + // when building the playground should skip further tests. + // If the page remains open, a command like `await page.click(...)` produces + // a timeout with an exception that hides the real error in the console. + await page.close() } }, 30000)