Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use jest v29 #17151

Merged
merged 3 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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": [],
}
`;