Skip to content

Commit

Permalink
馃彈Make babel plugin tests work with jest v25 (ampproject#28002)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha authored and ldoroshe committed May 8, 2020
1 parent 9900d34 commit 3a6b57b
Show file tree
Hide file tree
Showing 3 changed files with 889 additions and 52 deletions.
36 changes: 17 additions & 19 deletions build-system/tasks/babel-plugin-tests.js
Expand Up @@ -15,29 +15,27 @@
*/
'use strict';

const gulp = require('gulp');
const jest = require('gulp-jest').default;
const jest = require('@jest/core');
const {isTravisBuild} = require('../common/travis');

/**
* Simple wrapper around the jest tests for custom babel plugins.
* @return {!Vinyl}
* Entry point for `gulp babel-plugin-tests`. Runs the jest-based tests for
* AMP's custom babel plugins.
*/
function babelPluginTests() {
return gulp.src('./build-system/babel-plugins/testSetupFile.js').pipe(
jest({
'testRegex': '/babel-plugins/[^/]+/test/.+\\.m?js$',
'testPathIgnorePatterns': ['/node_modules/'],
'testEnvironment': 'node',
'transformIgnorePatterns': ['/node_modules/'],
'coveragePathIgnorePatterns': ['/node_modules/'],
'modulePathIgnorePatterns': ['/test/fixtures/', '<rootDir>/build/'],
'reporters': [
isTravisBuild() ? 'jest-silent-reporter' : 'jest-dot-reporter',
],
'automock': false,
})
);
async function babelPluginTests() {
const projects = ['./build-system/babel-plugins'];
const options = {
automock: false,
coveragePathIgnorePatterns: ['/node_modules/'],
modulePathIgnorePatterns: ['/test/fixtures/', '<rootDir>/build/'],
reporters: [isTravisBuild() ? 'jest-silent-reporter' : 'jest-dot-reporter'],
setupFiles: ['./build-system/babel-plugins/testSetupFile.js'],
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/'],
testRegex: '/babel-plugins/[^/]+/test/.+\\.m?js$',
transformIgnorePatterns: ['/node_modules/'],
};
await jest.runCLI(options, projects);
}

module.exports = {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"@babel/plugin-transform-react-constant-elements": "7.9.0",
"@babel/plugin-transform-react-jsx": "7.9.4",
"@babel/preset-env": "7.9.5",
"@jest/core": "25.4.0",
"@types/minimist": "1.2.0",
"acorn-globals": "6.0.0",
"amphtml-validator": "1.0.30",
Expand Down Expand Up @@ -106,7 +107,6 @@
"gulp-help": "chmontgomery/gulp-help#gulp4",
"gulp-if": "3.0.0",
"gulp-istanbul": "1.1.3",
"gulp-jest": "4.0.3",
"gulp-jsonlint": "1.3.2",
"gulp-jsonminify": "1.1.0",
"gulp-nop": "0.0.3",
Expand All @@ -117,7 +117,6 @@
"gulp-watch": "5.0.1",
"gzip-size": "5.1.1",
"html-minifier": "4.0.0",
"jest-cli": "24.9.0",
"jest-dot-reporter": "1.0.12",
"jest-silent-reporter": "0.2.1",
"jison": "0.4.18",
Expand Down

0 comments on commit 3a6b57b

Please sign in to comment.