From cf26c2846e87860ccf71361749adc9663a971e04 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 30 Mar 2019 15:51:36 +0100 Subject: [PATCH] pr feedback --- e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap | 12 ++++++++---- packages/jest-message-util/src/index.ts | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap b/e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap index 8b9e2e9f6451..48b50114e619 100644 --- a/e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap +++ b/e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap @@ -7,7 +7,8 @@ exports[`Wrong globals for environment print useful error for document 1`] = ` ● use document - Jest: You should use a jsdom test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + Consider using the \\"jsdom\\" test environment. ReferenceError: document is not defined @@ -28,7 +29,8 @@ exports[`Wrong globals for environment print useful error for unref 1`] = ` ● use unref - Jest: You should use a node test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + Consider using the \\"node\\" test environment. TypeError: setTimeout(...).unref is not a function @@ -50,7 +52,8 @@ exports[`Wrong globals for environment print useful error for window 1`] = ` ● use window - Jest: You should use a jsdom test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + Consider using the \\"jsdom\\" test environment. ReferenceError: window is not defined @@ -69,7 +72,8 @@ exports[`Wrong globals for environment print useful error when it explodes durin "FAIL __tests__/beforeTest.js ● Test suite failed to run - Jest: You should use a jsdom test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string. + Consider using the \\"jsdom\\" test environment. ReferenceError: document is not defined diff --git a/packages/jest-message-util/src/index.ts b/packages/jest-message-util/src/index.ts index ad25fc7c09d4..ee359a16bd81 100644 --- a/packages/jest-message-util/src/index.ts +++ b/packages/jest-message-util/src/index.ts @@ -105,10 +105,10 @@ function checkForCommonEnvironmentErrors(error: string) { function warnAboutWrongTestEnvironment(error: string, env: 'jsdom' | 'node') { return ( - chalk.red( - chalk.bold( - `Jest: You should use a ${env} test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.\n\n`, - ), + chalk.bold.red( + `The error below may be caused by using the wrong test environment, see ${chalk.dim.underline( + 'https://jestjs.io/docs/en/configuration#testenvironment-string', + )}.\nConsider using the "${env}" test environment.\n\n`, ) + error ); }