Skip to content

Commit

Permalink
Follow-up: Test: Collapse passed tests in Travis. (#18896)
Browse files Browse the repository at this point in the history
* Scripts: Fold passed test suites in E2E tests.

* Jest Preset Default: Delegate choosing reporter to the preset file.
  • Loading branch information
epiqueras authored Dec 3, 2019
1 parent 68f0dc5 commit ff92da2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 55 deletions.
31 changes: 31 additions & 0 deletions packages/jest-preset-default/jest-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
moduleNameMapper: {
'\\.(scss|css)$':
'<rootDir>/node_modules/@wordpress/jest-preset-default/scripts/style-mock.js',
},
modulePaths: [ '<rootDir>' ],
setupFiles: [
'<rootDir>/node_modules/@wordpress/jest-preset-default/scripts/setup-globals.js',
],
setupFilesAfterEnv: [
'<rootDir>/node_modules/@wordpress/jest-preset-default/scripts/setup-test-framework.js',
],
snapshotSerializers: [ '<rootDir>/node_modules/enzyme-to-json/serializer.js' ],
testMatch: [
'**/__tests__/**/*.[jt]s',
'**/test/*.[jt]s',
'**/?(*.)test.[jt]s',
],
testPathIgnorePatterns: [ '/node_modules/', '/wordpress/' ],
timers: 'fake',
transform: {
'^.+\\.[jt]sx?$': '<rootDir>/node_modules/babel-jest',
},
verbose: true,
reporters:
'TRAVIS' in process.env && 'CI' in process.env ?
[
'../../../@wordpress/jest-preset-default/scripts/travis-fold-passes-reporter.js',
] :
undefined,
};
32 changes: 0 additions & 32 deletions packages/jest-preset-default/jest-preset.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* External dependencies
*/
const { VerboseReporter, DefaultReporter } = require( '@jest/reporters' );
const { VerboseReporter } = require( '@jest/reporters' );

class TravisFoldPassesReporter extends VerboseReporter {
module.exports = class TravisFoldPassesReporter extends VerboseReporter {
constructor( ...args ) {
super( ...args );
this.foldedTestResults = [];
Expand Down Expand Up @@ -39,16 +39,4 @@ class TravisFoldPassesReporter extends VerboseReporter {
this.flushFoldedTestResults();
super.onRunComplete( ...args );
}
}

module.exports =
'TRAVIS' in process.env && 'CI' in process.env ?
TravisFoldPassesReporter :
class VerboseOrDefaultReporter {
constructor( globalConfig, ...args ) {
return new ( globalConfig.verbose ? VerboseReporter : DefaultReporter )(
globalConfig,
...args
);
}
};
};
16 changes: 8 additions & 8 deletions packages/scripts/config/jest-e2e.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const { hasBabelConfig } = require( '../utils' );

const jestE2EConfig = {
preset: 'jest-puppeteer',
testMatch: [
'**/specs/**/*.[jt]s',
'**/?(*.)spec.[jt]s',
],
testPathIgnorePatterns: [
'/node_modules/',
'/wordpress/',
],
testMatch: [ '**/specs/**/*.[jt]s', '**/?(*.)spec.[jt]s' ],
testPathIgnorePatterns: [ '/node_modules/', '/wordpress/' ],
reporters:
'TRAVIS' in process.env && 'CI' in process.env ?
[
'@wordpress/jest-preset-default/scripts/travis-fold-passes-reporter.js',
] :
undefined,
};

if ( ! hasBabelConfig() ) {
Expand Down

0 comments on commit ff92da2

Please sign in to comment.