From 1982c77f229591b0e7f07aec47ac48b580088d9a Mon Sep 17 00:00:00 2001 From: Mike MacCana Date: Fri, 27 Jan 2023 16:19:07 +0000 Subject: [PATCH 1/4] fix: make timeouts on a test refer to timeout parameter, rather than jest.setTimeout() --- packages/jest-circus/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index d45bf21e91f5..bce99ccacf1c 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -174,7 +174,7 @@ export const describeBlockHasTests = ( const _makeTimeoutMessage = (timeout: number, isHook: boolean) => `Exceeded timeout of ${formatTime(timeout)} for a ${ isHook ? 'hook' : 'test' - }.\nUse jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test.`; + }.\nAdd a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout.`; // Global values can be overwritten by mocks or tests. We'll capture // the original values in the variables before we require any files. From b65b5a430fad366e8961bb87c8767354538fb324 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 23 Feb 2023 09:59:45 +0100 Subject: [PATCH 2/4] update test replacement --- e2e/__tests__/failures.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e/__tests__/failures.test.ts b/e2e/__tests__/failures.test.ts index f9b61caeeaea..ca4c1cdd12c0 100644 --- a/e2e/__tests__/failures.test.ts +++ b/e2e/__tests__/failures.test.ts @@ -64,7 +64,10 @@ test('works with async failures', () => { // Remove replacements when jasmine is gone const result = normalizeDots(rest) .replace(/.*thrown:.*\n/, '') - .replace(/.*Use jest\.setTimeout\(newTimeout\).*/, '') + .replace( + /.*Add a timeout value to this test to increase the timeout, if this is a long-running test. See https:\/\/jestjs.io\/docs\/api#testname-fn-timeout..*/, + '', + ) .replace(/.*Timeout - Async callback was not.*/, ''); expect(result).toMatchSnapshot(); From 60533817fdf2984c1dcbe4bccd5abfa1a815efe5 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 23 Feb 2023 10:00:21 +0100 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cde23dbe2ce7..0ebe6a8e694c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Fixes - `[jest-circus]` Send test case results for `todo` tests ([#13915](https://github.com/facebook/jest/pull/13915)) +- `[jest-circus]` Update message printed on timeout ([#13830](https://github.com/facebook/jest/pull/13830)) ### Chore & Maintenance From b767c1568de4d1b0a477e451a49dca086d592236 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 23 Feb 2023 10:01:53 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ebe6a8e694c..c7ad54d3e307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ ### Fixes - `[jest-circus]` Send test case results for `todo` tests ([#13915](https://github.com/facebook/jest/pull/13915)) -- `[jest-circus]` Update message printed on timeout ([#13830](https://github.com/facebook/jest/pull/13830)) +- `[jest-circus]` Update message printed on test timeout ([#13830](https://github.com/facebook/jest/pull/13830)) ### Chore & Maintenance