From 4c79836616dbd8904af881c0388dc524ab95b374 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 26 Apr 2021 15:48:37 +0800 Subject: [PATCH] Add CHANGELOG and use jest-circus in unit tests as well --- packages/scripts/CHANGELOG.md | 1 + packages/scripts/config/jest-environment-puppeteer/index.js | 4 ++-- packages/scripts/config/jest-unit.config.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 9eb8af12fe4e4..6f600a91413d9 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -6,6 +6,7 @@ - Include a Jest Reporter that formats test results for GitHub Actions annotations ([#31041](https://github.com/WordPress/gutenberg/pull/31041)). - Have the `format` command ignore files listed in a `.prettierignore` file, add a fallback `.prettierignore` to the package ([30844](https://github.com/WordPress/gutenberg/pull/30844)). +- The e2e tests are now using [`jest-circus`](https://github.com/facebook/jest/tree/master/packages/jest-circus) as the test runner. This enable us to capture screenshots at the time the tests failed. The unit tests are also using the same test runner for consistency ([#28449](https://github.com/WordPress/gutenberg/pull/28449), [#31178](https://github.com/WordPress/gutenberg/pull/31178)). ### Breaking Changes diff --git a/packages/scripts/config/jest-environment-puppeteer/index.js b/packages/scripts/config/jest-environment-puppeteer/index.js index 76f1b4db2ba69..bb8d5bbda00c9 100644 --- a/packages/scripts/config/jest-environment-puppeteer/index.js +++ b/packages/scripts/config/jest-environment-puppeteer/index.js @@ -205,11 +205,11 @@ class PuppeteerEnvironment extends NodeEnvironment { replacement: '-', } ); await writeFile( - `${ ARTIFACTS_PATH }/${ fileName }-snapshot.html`, + path.join( ARTIFACTS_PATH, `${ fileName }-snapshot.html` ), await this.global.page.content() ); await this.global.page.screenshot( { - path: `${ ARTIFACTS_PATH }/${ fileName }.jpg`, + path: path.join( ARTIFACTS_PATH, `${ fileName }.jpg` ), } ); } diff --git a/packages/scripts/config/jest-unit.config.js b/packages/scripts/config/jest-unit.config.js index a5ad97acd1c00..a6228f60b02d5 100644 --- a/packages/scripts/config/jest-unit.config.js +++ b/packages/scripts/config/jest-unit.config.js @@ -9,6 +9,7 @@ const path = require( 'path' ); const { hasBabelConfig } = require( '../utils' ); const jestUnitConfig = { + testRunner: 'jest-circus/runner', preset: '@wordpress/jest-preset-default', reporters: [ 'default',