From 054d623f8e3265853f7134fed66f4aa9342b57b2 Mon Sep 17 00:00:00 2001 From: Matteo Dell'Acqua <82184604+MatteoH2O1999@users.noreply.github.com> Date: Tue, 17 Jan 2023 19:26:29 +0100 Subject: [PATCH] Flip silent default value and fix worker shutdown --- docs/Configuration.md | 2 +- .../jest-reporters/src/GitHubActionsReporter.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 8260dbab97aa..eebddd813855 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1278,7 +1278,7 @@ export default config; #### GitHub Actions Reporter -If included in the list, the built-in GitHub Actions Reporter will annotate changed files with test failure messages and print logs with github group features for easy navigation. Note that `'default'` should not be used in this case as `'github-actions'` will handle that already, so remember to also include `'summary'`. If you wish to use it only for annotations simply pass `'silent: true'` as option (default is `false`): +If included in the list, the built-in GitHub Actions Reporter will annotate changed files with test failure messages and (if used with `'silent: false'`) print logs with github group features for easy navigation. Note that `'default'` should not be used in this case as `'github-actions'` will handle that already, so remember to also include `'summary'`. If you wish to use it only for annotations simply leave only the reporter without options as the default value of `'silent'` is `'true'`: ```js tab /** @type {import('jest').Config} */ diff --git a/packages/jest-reporters/src/GitHubActionsReporter.ts b/packages/jest-reporters/src/GitHubActionsReporter.ts index 2b5243de5d04..7d439b182111 100644 --- a/packages/jest-reporters/src/GitHubActionsReporter.ts +++ b/packages/jest-reporters/src/GitHubActionsReporter.ts @@ -66,10 +66,15 @@ export default class GitHubActionsReporter extends BaseReporter { constructor( _globalConfig: Config.GlobalConfig, - reporterOptions: {silent?: boolean} = {silent: false}, + reporterOptions: {silent?: boolean} = {silent: true}, ) { super(); - this.options = {silent: reporterOptions.silent || false}; + this.options = { + silent: + typeof reporterOptions.silent === 'boolean' + ? reporterOptions.silent + : true, + }; } override onTestResult( @@ -215,12 +220,10 @@ export default class GitHubActionsReporter extends BaseReporter { root.passed = false; passed = false; } - if (!element.duration || isNaN(element.duration)) { - throw new Error('Expected duration to be a number, got NaN'); - } + const duration = element.duration || 1; root.children.push({ children: [], - duration: Math.max(element.duration, 1), + duration, name: element.title, passed, });