From 8901dac384f815b713184c40efc55cd25f7cac13 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 14 Jun 2023 21:29:49 +0800 Subject: [PATCH] test: reduce CI failure --- __tests__/jest.non-parallel.config.js | 4 ++++ __tests__/setup.ts | 1 + src/utils/getSafeWidth.test.ts | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 __tests__/setup.ts diff --git a/__tests__/jest.non-parallel.config.js b/__tests__/jest.non-parallel.config.js index c874fea..599e24b 100644 --- a/__tests__/jest.non-parallel.config.js +++ b/__tests__/jest.non-parallel.config.js @@ -1,7 +1,11 @@ const baseConfig = require('./jest.config') +/** + * @type {import('@jest/types').Config.InitialOptions} + */ module.exports = { ...baseConfig, maxWorkers: 1, testMatch: [...baseConfig.testMatch, '**/__tests__/cases/non-parallel/*.ts?(x)'], + setupFilesAfterEnv: ['/setup.ts'], } diff --git a/__tests__/setup.ts b/__tests__/setup.ts new file mode 100644 index 0000000..05366db --- /dev/null +++ b/__tests__/setup.ts @@ -0,0 +1 @@ +jest.retryTimes(3) diff --git a/src/utils/getSafeWidth.test.ts b/src/utils/getSafeWidth.test.ts index 3fa04f6..ca3fdb1 100644 --- a/src/utils/getSafeWidth.test.ts +++ b/src/utils/getSafeWidth.test.ts @@ -1,5 +1,7 @@ import { getSafeWidth, MINIMAL_CONTENT_VIEWPORT_WIDTH, MINIMAL_WIDTH } from './getSafeWidth' +jest.retryTimes(3) // Math.random may result in failure due to floating point precision + it(`should shrink when window is being resized smaller`, () => { const randomGrow = 100 * Math.random() expect(