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

🏗Make babel plugin tests work with jest v25 #28002

Merged
merged 2 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions build-system/tasks/babel-plugin-tests.js
Original file line number Diff line number Diff line change
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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
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 Expand Up @@ -198,6 +197,8 @@
"dist/*.mjs",
"dist/v0/*-?.?.mjs"
],
"trackFormat": ["brotli"]
"trackFormat": [
"brotli"
]
}
}
Loading