Skip to content

Commit

Permalink
test: use jest v29
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Aug 12, 2022
1 parent 9f837f2 commit 37e5d01
Show file tree
Hide file tree
Showing 185 changed files with 10,826 additions and 10,719 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
run: yarn build

- name: Unit tests
run: yarn jest:${{ env.NODE_VERSION }} --maxWorkers=2 --ci --coverage ${{ env.coverage }}
run: yarn jest --ci --coverage ${{ env.coverage }}

- name: Codecov
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # tag=v3.1.0
Expand Down
44 changes: 36 additions & 8 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
import os from 'os';
import type { InitialOptionsTsJest } from 'ts-jest/dist/types';

const ci = !!process.env.CI;

const config: InitialOptionsTsJest = {
type JestConfig = InitialOptionsTsJest & {
// https://github.com/renovatebot/renovate/issues/17034
workerIdleMemoryLimit?: string;
};

/**
* https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
*/
function jestGithubRunnerSpecs(): JestConfig {
if (os.platform() === 'darwin') {
//
return {
maxWorkers: 2,
workerIdleMemoryLimit: '4GB',
};
}

return {
maxWorkers: 2,
workerIdleMemoryLimit: '2GB',
};
}

const config: JestConfig = {
preset: 'ts-jest',
cacheDirectory: '.cache/jest',
coverageDirectory: './coverage',
Expand All @@ -24,6 +48,13 @@ const config: InitialOptionsTsJest = {
statements: 100,
},
},
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
isolatedModules: true,
},
},
modulePathIgnorePatterns: ['<rootDir>/dist/', '/__fixtures__/'],
reporters: ci ? ['default', 'github-actions'] : ['default'],
setupFilesAfterEnv: [
Expand All @@ -36,13 +67,10 @@ const config: InitialOptionsTsJest = {
testEnvironment: 'node',
testRunner: 'jest-circus/runner',
watchPathIgnorePatterns: ['<rootDir>/.cache/', '<rootDir>/coverage/'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
isolatedModules: true,
},
},
// We can play with that value later for best dev experience
workerIdleMemoryLimit: '500MB',
// add github runner specific limits
...(ci && jestGithubRunnerSpecs()),
};

export default config;
8 changes: 4 additions & 4 deletions lib/config/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config/index mergeChildConfig(parentConfig, childConfig) merges 1`] = `
Object {
{
"branchTopic": "lock-file-maintenance",
"commitMessageAction": "Lock file maintenance",
"commitMessageExtra": null,
"commitMessageTopic": null,
"enabled": false,
"groupName": null,
"prBodyDefinitions": Object {
"prBodyDefinitions": {
"Change": "All locks refreshed",
},
"rebaseStalePrs": true,
"recreateClosed": true,
"schedule": Array [
"schedule": [
"on monday",
],
}
`;

exports[`config/index mergeChildConfig(parentConfig, childConfig) merges constraints 1`] = `
Object {
{
"node": "<15",
"npm": "^6.0.0",
}
Expand Down
34 changes: 17 additions & 17 deletions lib/config/__snapshots__/massage.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config/massage massageConfig does not massage lockFileMaintenance 1`] = `
Object {
"packageRules": Array [
Object {
"lockFileMaintenance": Object {
{
"packageRules": [
{
"lockFileMaintenance": {
"enabled": true,
},
"matchBaseBranches": Array [
"matchBaseBranches": [
"release/ft10/1.9.x",
],
"matchManagers": Array [
"matchManagers": [
"helmv3",
],
"schedule": Array [
"schedule": [
"at any time",
],
},
Expand All @@ -22,28 +22,28 @@ Object {
`;

exports[`config/massage massageConfig massages packageRules matchUpdateTypes 1`] = `
Object {
"packageRules": Array [
Object {
"matchPackageNames": Array [
{
"packageRules": [
{
"matchPackageNames": [
"foo",
],
"separateMajorMinor": false,
},
Object {
"matchPackageNames": Array [
{
"matchPackageNames": [
"foo",
],
"matchUpdateTypes": Array [
"matchUpdateTypes": [
"minor",
],
"semanticCommitType": "feat",
},
Object {
"matchPackageNames": Array [
{
"matchPackageNames": [
"foo",
],
"matchUpdateTypes": Array [
"matchUpdateTypes": [
"patch",
],
"semanticCommitType": "fix",
Expand Down
12 changes: 6 additions & 6 deletions lib/config/__snapshots__/migrate-validate.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config/migrate-validate migrateAndValidate() handles invalid 1`] = `
Object {
"errors": Array [
Object {
{
"errors": [
{
"message": "Invalid configuration option: foo",
"topic": "Configuration Error",
},
],
"foo": "none",
"warnings": Array [],
"warnings": [],
}
`;

exports[`config/migrate-validate migrateAndValidate() isOnboarded 1`] = `
Object {
"errors": Array [],
{
"errors": [],
}
`;

0 comments on commit 37e5d01

Please sign in to comment.