Skip to content

Commit

Permalink
chore(package): run react tests in ci (carbon-design-system#3120)
Browse files Browse the repository at this point in the history
* chore(package): run react tests in ci

* chore(jest): update root test setup

* chore(project): update jsTransform at top-level

* chore(project): update request-animation-frame polyfill in test

* chore(project): update coverage options for jest
  • Loading branch information
joshblack authored Jun 20, 2019
1 parent 91c7c4a commit ee5cdd9
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ packages/components/node_modules

# Sketch
*.sketchplugin

# React
**/storybook-static/**
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ packages/components/css
packages/components/scss
packages/components/docs/js

# React
**/storybook-static/**

# Sketch
**/*.sketchplugin/**

Expand Down
Binary file not shown.
Binary file added .yarn/offline-mirror/cross-spawn-4.0.2.tgz
Binary file not shown.
Binary file added .yarn/offline-mirror/enzyme-3.10.0.tgz
Binary file not shown.
Binary file removed .yarn/offline-mirror/enzyme-3.9.0.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/offline-mirror/node-version-1.2.0.tgz
Binary file not shown.
Binary file added .yarn/offline-mirror/promise-polyfill-6.1.0.tgz
Binary file not shown.
19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
},
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
Expand All @@ -39,6 +42,9 @@
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"doctoc": "^1.4.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.3.5",
"eslint": "^5.16.0",
"eslint-config-carbon": "10.3.0",
"eslint-plugin-jsdoc": "^7.2.3",
Expand All @@ -53,6 +59,8 @@
"lerna": "^3.13.4",
"lint-staged": "^8.1.5",
"prettier": "^1.17.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"stylelint": "^10.0.1"
},
Expand Down Expand Up @@ -118,7 +126,10 @@
},
"jest": {
"collectCoverageFrom": [
"packages/**/*.js"
"packages/**/src/**/*.js",
"!packages/{bundler,cli,components,sketch}/**",
"!packages/**/{examples,stories}/**",
"!**/*-story.js"
],
"moduleFileExtensions": [
"js",
Expand All @@ -131,6 +142,9 @@
"setupFiles": [
"./tasks/jest/setup.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"testMatch": [
"<rootDir>/**/__tests__/**/*.js?(x)",
"<rootDir>/**/?(*.)(spec|test).js?(x)",
Expand All @@ -149,8 +163,7 @@
"/lib/",
"e2e",
"examples",
"/umd/",
"/packages/react/"
"/umd/"
],
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"dependencies": {
"@carbon/cli-reporter": "10.2.0",
"child-process-promise": "^2.2.1",
"fs-extra": "^8.0.1",
"prettier": "^1.18.2",
"remark": "^10.0.1",
Expand Down
35 changes: 12 additions & 23 deletions packages/cli/src/commands/ci-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,35 @@
'use strict';

const { reporter } = require('@carbon/cli-reporter');
const childProcess = require('child_process');
const util = require('util');
const { exec } = require('child-process-promise');
const { workspace } = require('../workspace');

const exec = util.promisify(childProcess.exec);

async function check(args, env) {
reporter.info('Running checks in CI...');

const options = {
cwd: env.root.directory,
stdio: 'inherit',
};
const tasks = [
'yarn format:diff',
'yarn lint',
'yarn format:diff --loglevel=silent',
'yarn lint --quiet',
`yarn bundler check --ignore '**/@(node_modules|examples|components|react)/**' 'packages/**/*.scss'`,
`cross-env BABEL_ENV=test yarn test --ci --maxWorkers 2 --reporters=default --reporters=jest-junit`,
`cross-env BABEL_ENV=test yarn test:e2e --ci --maxWorkers 2 --reporters=default --reporters=jest-junit`,
];

reporter.info('Running the following tasks:');
for (let i = 0; i < tasks.length; i++) {
reporter.info(`[${i}] ${tasks[i]}`);
}

const promise = Promise.all(tasks.map(task => exec(task, options)));
const interval = setInterval(() => {
process.stdout.write('.');
}, 1000);

try {
await promise;
clearInterval(interval);
console.log();
reporter.success('Done! 🎉');
for (const task of tasks) {
const now = Date.now();

reporter.info(`Running: ${task}`);
await exec(task, options);
reporter.success(`Done in: ${Date.now() - now}ms`);
}
} catch (error) {
clearInterval(interval);
console.log();
console.log(error.message);
console.log(error.stdout);
console.log(error.stderr);
process.exit(1);
}
}
Expand Down
3 changes: 0 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@
"core-js": "^3.1.3",
"cross-env": "^5.2.0",
"css-loader": "^1.0.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.12.1",
"enzyme-to-json": "^3.3.5",
"eslint-plugin-react-hooks": "^1.6.0",
"gzip-size": "^5.0.0",
"jest": "^24.0.0",
Expand Down
7 changes: 7 additions & 0 deletions tasks/jest/cssTransform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

// This is a custom Jest transformer turning style imports into empty objects.
Expand Down
7 changes: 7 additions & 0 deletions tasks/jest/fileTransform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const path = require('path');
Expand Down
10 changes: 10 additions & 0 deletions tasks/jest/jsTransform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const { createTransformer } = require('babel-jest');
Expand All @@ -15,6 +22,9 @@ const babelOptions = {
'@babel/preset-react',
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
[
'@babel/plugin-transform-runtime',
{
Expand Down
18 changes: 17 additions & 1 deletion tasks/jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

global.__DEV__ = true;

global.requestAnimationFrame = function requestAnimationFrame(callback) {
setTimeout(callback);
// TODO: replace with async version
// setTimeout(callback);
callback();
};

const enzyme = require.requireActual('enzyme');
const Adapter = require.requireActual('enzyme-adapter-react-16');

enzyme.configure({ adapter: new Adapter() });
49 changes: 38 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"@babel/helper-create-class-features-plugin" "^7.4.0"
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.3.3", "@babel/plugin-proposal-class-properties@^7.4.0":
"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.3.3", "@babel/plugin-proposal-class-properties@^7.4.0", "@babel/plugin-proposal-class-properties@^7.4.4":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.4.4.tgz#93a6486eed86d53452ab9bab35e368e9461198ce"
integrity sha512-WjKTI8g8d5w1Bc9zgwSz2nfrsNQsXcCf9J9cdCvrJV6RF56yztwm4TmJC0MgJ9tvwO9gUA/mcYe89bLdGfiXFg==
Expand Down Expand Up @@ -5766,6 +5766,15 @@ cheerio@^1.0.0-rc.2:
lodash "^4.15.0"
parse5 "^3.0.1"

child-process-promise@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/child-process-promise/-/child-process-promise-2.2.1.tgz#4730a11ef610fad450b8f223c79d31d7bdad8074"
integrity sha1-RzChHvYQ+tRQuPIjx50x172tgHQ=
dependencies:
cross-spawn "^4.0.2"
node-version "^1.0.0"
promise-polyfill "^6.0.1"

chokidar@^1.4.2, chokidar@^1.6.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
Expand Down Expand Up @@ -6789,6 +6798,14 @@ cross-spawn@^3.0.0:
lru-cache "^4.0.1"
which "^1.2.9"

cross-spawn@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41"
integrity sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=
dependencies:
lru-cache "^4.0.1"
which "^1.2.9"

cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
Expand Down Expand Up @@ -7983,10 +8000,10 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"

enzyme-adapter-react-16@^1.12.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.13.1.tgz#2e8ee300e38674b9914ae52b04af9493050355e2"
integrity sha512-DCKbkiVlfLTbn4SXO8mXDQx1SmmwON5oKXn2QfQSMCt8eTYGwUXy/OBGSuss6KKwY5w5QfK1sQFxhgFOkMCjrw==
enzyme-adapter-react-16@^1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.14.0.tgz#204722b769172bcf096cb250d33e6795c1f1858f"
integrity sha512-7PcOF7pb4hJUvjY7oAuPGpq3BmlCig3kxXGi2kFx0YzJHppqX1K8IIV9skT1IirxXlu8W7bneKi+oQ10QRnhcA==
dependencies:
enzyme-adapter-utils "^1.12.0"
has "^1.0.3"
Expand All @@ -7995,7 +8012,7 @@ enzyme-adapter-react-16@^1.12.1:
prop-types "^15.7.2"
react-is "^16.8.6"
react-test-renderer "^16.0.0-0"
semver "^5.6.0"
semver "^5.7.0"

enzyme-adapter-utils@^1.12.0:
version "1.12.0"
Expand All @@ -8016,10 +8033,10 @@ enzyme-to-json@^3.3.5:
dependencies:
lodash "^4.17.4"

enzyme@^3.9.0:
version "3.9.0"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.9.0.tgz#2b491f06ca966eb56b6510068c7894a7e0be3909"
integrity sha512-JqxI2BRFHbmiP7/UFqvsjxTirWoM1HfeaJrmVSZ9a1EADKkZgdPcAuISPMpoUiHlac9J4dYt81MC5BBIrbJGMg==
enzyme@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.10.0.tgz#7218e347c4a7746e133f8e964aada4a3523452f6"
integrity sha512-p2yy9Y7t/PFbPoTvrWde7JIYB2ZyGC+NgTNbVEGvZ5/EyoYSr9aG/2rSbVvyNvMHEhw9/dmGUJHWtfQIEiX9pg==
dependencies:
array.prototype.flat "^1.2.1"
cheerio "^1.0.0-rc.2"
Expand Down Expand Up @@ -14599,6 +14616,11 @@ node-status-codes@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/node-status-codes/-/node-status-codes-1.0.0.tgz#5ae5541d024645d32a58fcddc9ceecea7ae3ac2f"

node-version@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/node-version/-/node-version-1.2.0.tgz#34fde3ffa8e1149bd323983479dda620e1b5060d"
integrity sha512-ma6oU4Sk0qOoKEAymVoTvk8EdXEobdS7m/mAGhDJ8Rouugho48crHBORAmy5BoOcv8wraPM6xumapQp5hl4iIQ==

nodemon@^1.18.7:
version "1.19.0"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.19.0.tgz#358e005549a1e9e1148cb2b9b8b28957dc4e4527"
Expand Down Expand Up @@ -16570,6 +16592,11 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

promise-polyfill@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-6.1.0.tgz#dfa96943ea9c121fca4de9b5868cb39d3472e057"
integrity sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc=

promise-polyfill@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.1.0.tgz#30059da54d1358ce905ac581f287e184aedf995d"
Expand Down Expand Up @@ -18582,7 +18609,7 @@ semver-regex@^1.0.0:
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-1.0.0.tgz#92a4969065f9c70c694753d55248fc68f8f652c9"
integrity sha1-kqSWkGX5xwxpR1PVUkj8aPj2Usk=

"semver@2 || 3 || 4 || 5", "[email protected] || 3.x || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
"semver@2 || 3 || 4 || 5", "[email protected] || 3.x || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
Expand Down

0 comments on commit ee5cdd9

Please sign in to comment.