Skip to content

Commit

Permalink
test(cli): work around jest not respecting test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2022
1 parent 316a2ff commit 0b7070b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@sanity/cli/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = createJestConfig({
globalTeardown: '<rootDir>/test/shared/globalTeardown.ts',
slowTestThreshold: 60000,
testTimeout: 30000,
setupFilesAfterEnv: ['<rootDir>/test/shared/setupAfterEnv.ts'],
})
11 changes: 11 additions & 0 deletions packages/@sanity/cli/test/shared/setupAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Jest has a bug where it does not respect the project `testTimeout`:
* https://github.com/facebook/jest/issues/9696
*
* To prevent having to redeclare a timeout for every single tests, we use this as a replacement
* (we need a little more leeway on these CLI tests, they are quite slow)
*/

jest.setTimeout(30000) // 30s

export {}

0 comments on commit 0b7070b

Please sign in to comment.