From 8f918e05925d53e685a797b43cdbae16d77920f9 Mon Sep 17 00:00:00 2001 From: alisman Date: Tue, 24 May 2022 15:37:42 -0400 Subject: [PATCH] Split unit tests into two jobs. Fix JEST report output --- .circleci/config.yml | 34 ++++++++++++++--- package.json | 6 ++- .../cbioportal-clinical-timeline/package.json | 2 +- .../cbioportal-frontend-commons/package.json | 2 +- packages/cbioportal-utils/package.json | 2 +- packages/react-mutation-mapper/package.json | 2 +- .../TableHeaderControls.spec.tsx | 6 +-- yarn.lock | 37 +++++++++++++++++++ 8 files changed, 77 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8aafa7d61fb..0bfff9e2704 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -139,16 +139,34 @@ jobs: - run: command: "yarn run test" environment: - JUNIT_REPORT_PATH: ./junit/ - JUNIT_REPORT_NAME: test-results.xml + JEST_JUNIT_OUTPUT_DIR: ./junit/unit/main/ + JEST_JUNIT_OUTPUT_NAME: test-results-unit-main.xml NODE_OPTIONS: --max-old-space-size=4096 DISABLE_SOURCEMAP: true WEBPACK_PARALLEL: false when: always - store_test_results: - path: /tmp/repo/junit - - store_artifacts: - path: /tmp/repo/junit + path: ./junit/unit/main/ + + unit_tests_packages: + <<: *defaults + steps: + # - run: + # name: "Install yarn at specific version" + # command: + # sudo npm install --global yarn@1.22.4 + - attach_workspace: + at: /tmp/ + # run tests! + - run: + command: "yarn run testModulesCI" + environment: + DISABLE_SOURCEMAP: true + NODE_OPTIONS: --max-old-space-size=4096 + WEBPACK_PARALLEL: false + when: always + - store_test_results: + path: /tmp/junit/module/ check_forgotten_spec_only_statements: <<: *defaults @@ -350,6 +368,9 @@ workflows: - unit_tests: requires: - install + - unit_tests_packages: + requires: + - install - end_to_end_tests: requires: - install @@ -382,6 +403,9 @@ workflows: - unit_tests: requires: - install + - unit_tests_packages: + requires: + - install - end_to_end_tests: requires: - install diff --git a/package.json b/package.json index ffbc2f275a7..190c9e62b70 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,9 @@ "serveDist": "./scripts/serve_dist.sh", "serveDistLocalDb": "./end-to-end-test/local/runtime-config/serve_dist.sh", "testTime": "start_time=`date +%s` && karma start karma.conf.js && echo run time is $(expr `date +%s` - $start_time) s", - "test": "yarn run testModules && yarn run testMain", - "testMain": "cross-env CI=1 jest --env=jsdom --runInBand", + "test": "yarn run testMain", + "testMain": "jest TableHeaderControls.spec.tsx --env=jsdom --runInBand --ci --reporters=default --reporters=jest-junit", + "testModulesCI" : "JEST_JUNIT_UNIQUE_OUTPUT_NAME=true JEST_JUNIT_OUTPUT_DIR=/tmp/junit/module/ JEST_JUNIT_OUTPUT_NAME=unit-test-module yarn run testModules", "testModules": "lerna run test --ignore=cbioportal-frontend --stream", "test:watch": "yarn run testMain:watch", "testMain:watch": "yarn run testMain --watch", @@ -354,6 +355,7 @@ "jest": "^27.2.1", "jest-canvas-mock": "^2.3.1", "jest-environment-jsdom": "^27.2.0", + "jest-junit": "^13.2.0", "json": "^9.0.6", "netlify": "^8.0.1", "node-fetch": "^2.6.1", diff --git a/packages/cbioportal-clinical-timeline/package.json b/packages/cbioportal-clinical-timeline/package.json index dc0ce478e28..f6122111fc1 100644 --- a/packages/cbioportal-clinical-timeline/package.json +++ b/packages/cbioportal-clinical-timeline/package.json @@ -27,7 +27,7 @@ "tcm": "tcm -p src/**/*.module.scss", "tcm:watch": "yarn run tcm --watch", "prepare": "yarn run build", - "test": "cross-env CI=1 jest --env=jsdom --runInBand", + "test": "cross-env jest --env=jsdom --runInBand --ci --reporters=default --reporters=jest-junit", "test:watch": "yarn run test --watch" }, "peerDependencies": { diff --git a/packages/cbioportal-frontend-commons/package.json b/packages/cbioportal-frontend-commons/package.json index c0c2206c40d..7bdaa17835d 100644 --- a/packages/cbioportal-frontend-commons/package.json +++ b/packages/cbioportal-frontend-commons/package.json @@ -27,7 +27,7 @@ "tcm": "tcm -p src/**/*.module.scss", "tcm:watch": "yarn run tcm --watch", "prepare": "yarn run build", - "test": "cross-env CI=1 jest --env=jsdom --runInBand", + "test": "cross-env jest --env=jsdom --runInBand --ci --reporters=default --reporters=jest-junit", "test:watch": "yarn run test --watch" }, "peerDependencies": { diff --git a/packages/cbioportal-utils/package.json b/packages/cbioportal-utils/package.json index 42790d3a48b..12560ae4066 100644 --- a/packages/cbioportal-utils/package.json +++ b/packages/cbioportal-utils/package.json @@ -25,7 +25,7 @@ "rollup": "rollup -c rollup.config.ts", "rollup:watch": "rollup -c rollup.config.ts -w", "prepare": "yarn run build", - "test": "cross-env CI=1 jest --env=jsdom --runInBand", + "test": "cross-env jest --env=jsdom --runInBand --ci --reporters=default --reporters=jest-junit", "test:watch": "yarn run test --watch" }, "dependencies": { diff --git a/packages/react-mutation-mapper/package.json b/packages/react-mutation-mapper/package.json index b9c5778d8f3..a9967f1f876 100644 --- a/packages/react-mutation-mapper/package.json +++ b/packages/react-mutation-mapper/package.json @@ -27,7 +27,7 @@ "tcm": "tcm -p src/**/*.module.scss", "tcm:watch": "yarn run tcm --watch", "prepare": "yarn run build", - "test": "cross-env CI=1 jest --env=jsdom --runInBand", + "test": "cross-env jest --env=jsdom --runInBand --ci --reporters=default --reporters=jest-junit", "test:watch": "yarn run test --watch" }, "peerDependencies": { diff --git a/src/shared/components/tableHeaderControls/TableHeaderControls.spec.tsx b/src/shared/components/tableHeaderControls/TableHeaderControls.spec.tsx index 10fbc6a7a20..1a99df26f74 100644 --- a/src/shared/components/tableHeaderControls/TableHeaderControls.spec.tsx +++ b/src/shared/components/tableHeaderControls/TableHeaderControls.spec.tsx @@ -29,17 +29,17 @@ describe('TableHeaderControls', () => { it('bindCopyButton is called only when there is a copy button and props flag is true', () => { let mockInstance = { bindCopyButton: sinon.stub(), - props: { showCopyAndDownload: true }, + showCopyAndDownload: true, _copyButton: {}, }; TableHeaderControls.prototype.componentDidMount.apply(mockInstance); - assert.isTrue(mockInstance.bindCopyButton.calledOnce); + assert.isTrue(mockInstance.bindCopyButton.called); mockInstance = { bindCopyButton: sinon.stub(), - props: { showCopyAndDownload: false }, + showCopyAndDownload: false, _copyButton: {}, }; diff --git a/yarn.lock b/yarn.lock index 0cc70e5d4de..e9cebab5fbf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5490,6 +5490,11 @@ ansi-regex@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + ansi-regex@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.0.tgz#ecc7f5933cbe5ac7b33e209a5ff409ab1669c6b2" @@ -14731,6 +14736,16 @@ jest-jasmine2@^27.2.1: pretty-format "^27.2.0" throat "^6.0.1" +jest-junit@^13.2.0: + version "13.2.0" + resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-13.2.0.tgz#66eeb86429aafac8c1745a70f44ace185aacb943" + integrity sha512-B0XNlotl1rdsvFZkFfoa19mc634+rrd8E4Sskb92Bb8MmSXeWV9XJGUyctunZS1W410uAxcyYuPUGVnbcOH8cg== + dependencies: + mkdirp "^1.0.4" + strip-ansi "^6.0.1" + uuid "^8.3.2" + xml "^1.0.1" + jest-leak-detector@^27.2.0: version "27.2.0" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.2.0.tgz#9a7ca2dad1a21c4e49ad2a8ad7f1214ffdb86a28" @@ -17098,6 +17113,11 @@ mkdirp@^0.5.5: dependencies: minimist "^1.2.5" +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + mobx-logger@^0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/mobx-logger/-/mobx-logger-0.7.1.tgz#6be44c726e14433463f5fa566f24f1768e2a9355" @@ -23522,6 +23542,13 @@ strip-ansi@^6.0.0: dependencies: ansi-regex "^5.0.0" +strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.0.tgz#1dc49b980c3a4100366617adac59327eefdefcb0" @@ -24992,6 +25019,11 @@ uuid@^3.4.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + uvu@^0.5.0: version "0.5.2" resolved "https://registry.yarnpkg.com/uvu/-/uvu-0.5.2.tgz#c145e7f4b5becf80099cf22fd8a4a05f0112b2c0" @@ -26018,6 +26050,11 @@ xml2js@^0.4.23: sax ">=0.6.0" xmlbuilder "~11.0.0" +xml@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= + xmlbuilder@~11.0.0: version "11.0.1" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"