Skip to content

Commit

Permalink
[CI] Resolve warnings in tests (#3873)
Browse files Browse the repository at this point in the history
This PR makes the following changes:

- Cleans up test warnings when running our jest test suites
- Adds a patch that resolves an issue with jest version 29
  - jestjs/jest#14513
  - This is resolved in jest 30 but it's still in beta
  • Loading branch information
sotojn authored Dec 17, 2024
1 parent d21aba3 commit 53e0d7f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
11 changes: 1 addition & 10 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { isCI } from '@terascope/utils';

const dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -31,15 +30,11 @@ export default (projectDir) => {
rootDir = '../../';
}

const coverageReporters = ['lcov', 'html'];
if (!isCI) {
coverageReporters.push('text-summary');
}
const config = {
rootDir,
displayName: name,
verbose: true,
testEnvironment: 'node',
testTimeout: 60 * 1000,
setupFilesAfterEnv: ['jest-extended/all'],
testMatch: [`${packageRoot}/test/**/*-spec.{ts,js}`, `${packageRoot}/test/*-spec.{ts,js}`],
testPathIgnorePatterns: [
Expand All @@ -57,14 +52,10 @@ export default (projectDir) => {
},
moduleFileExtensions: ['ts', 'js', 'json', 'node', 'pegjs', 'mjs'],
extensionsToTreatAsEsm: ['.ts'],
collectCoverage: true,
coveragePathIgnorePatterns: ['/node_modules/', '/test/'],
watchPathIgnorePatterns: [],
coverageReporters,
coverageDirectory: `${packageRoot}/coverage`,
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
workerIdleMemoryLimit: '200MB',
testTimeout: 60 * 1000,
globals: {
availableExtensions: ['.js', '.ts', '.mjs', 'cjs'],
},
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ if (!isCI) {
export default {
rootDir: '.',
verbose: true,
testTimeout: 60 * 1000,
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
projects,
globals: {
availableExtensions: ['.js', '.ts', '.mjs', '.cjs'],
Expand Down
10 changes: 10 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ npx patch-package package/another-package
### Updating patches

Use exactly the same process as for making patches in the first place, i.e. make more changes, run patch-package, commit the changes to the patch file.

## Current Patches

### jest-config

`jest-config` needed a patch that fixes an issue that's stated here:

[Unknown option testTimeout validation warning when used in project specific config](https://github.com/jestjs/jest/issues/14513)

This is fixed on jest version 30 but it's still in beta. Once out of beta, this patch can be removed.
12 changes: 12 additions & 0 deletions patches/jest-config+29.7.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/node_modules/jest-config/build/ValidConfig.js b/node_modules/jest-config/build/ValidConfig.js
index 0c1250c..67e586e 100644
--- a/node_modules/jest-config/build/ValidConfig.js
+++ b/node_modules/jest-config/build/ValidConfig.js
@@ -331,6 +331,7 @@ const initialProjectOptions = {
['/__tests__/\\.test\\.[jt]sx?$', '/__tests__/\\.spec\\.[jt]sx?$']
),
testRunner: 'circus',
+ testTimeout: 5000,
transform: {
'\\.js$': '<rootDir>/preprocessor.js'
},

0 comments on commit 53e0d7f

Please sign in to comment.