Skip to content

Commit

Permalink
Adds code coverage reporting
Browse files Browse the repository at this point in the history
* Renames build and test workflow to eliminate ambiguity.
* Adds coverage generation for jest and mocha tests.
* Expands coverage collection for jest tests.
* Utilizes `lcov` reporter as well as text summary reporter.

Resolves opensearch-project#1339
Prerequisite for opensearch-project#1035

Signed-off-by: Tommy Markley <[email protected]>
  • Loading branch information
Tommy Markley committed Apr 19, 2022
1 parent 68a4d9d commit 878139f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ jobs:
id: linter
run: yarn lint

- name: Run unit tests
- name: Run unit tests with coverage
id: unit-tests
run: yarn test:jest:ci
run: yarn test:jest:ci:coverage

- name: Run mocha tests
- name: Run mocha tests with coverage
id: mocha-tests
run: yarn test:mocha
run: yarn test:mocha:coverage

- name: Upload Code Coverage
id: upload-code-coverage
uses: codecov/codecov-action@v3
with:
directory: ./target/opensearch-dashboards-coverage

- name: Run integration tests
id: integration-tests
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@
"test": "grunt test",
"test:bwc": "./scripts/bwctest_osd.sh",
"test:jest": "node scripts/jest",
"test:jest:coverage": "node scripts/jest --coverage",
"test:jest:ci": "node scripts/jest --ci --colors --runInBand",
"test:jest:ci:coverage": "node scripts/jest --ci --colors --runInBand --coverage",
"test:jest_integration": "node scripts/jest_integration",
"test:jest_integration:ci": "node scripts/jest_integration --ci --colors --max-old-space-size=5120",
"test:mocha": "node scripts/mocha",
"test:mocha:coverage": "grunt test:mochaCoverage",
"test:mocha:coverage": "yarn nyc --reporter=text-summary --reporter=lcov --report-dir=./target/opensearch-dashboards-coverage/mocha node scripts/mocha",
"test:ftr": "node scripts/functional_tests",
"test:ftr:server": "node scripts/functional_tests_server",
"test:ftr:runner": "node scripts/functional_test_runner",
"test:coverage": "grunt test:coverage",
"checkLicenses": "node scripts/check_licenses --dev",
"build-platform": "node scripts/build",
"build": "node scripts/build --all-platforms",
Expand Down
13 changes: 2 additions & 11 deletions src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ export default {
'<rootDir>/src/test_utils',
'<rootDir>/test/functional/services/remote',
],
collectCoverageFrom: [
'src/plugins/**/*.{ts,tsx}',
'!src/plugins/**/*.d.ts',
'packages/osd-ui-framework/src/components/**/*.js',
'!packages/osd-ui-framework/src/components/index.js',
'!packages/osd-ui-framework/src/components/**/*/index.js',
'packages/osd-ui-framework/src/services/**/*.js',
'!packages/osd-ui-framework/src/services/index.js',
'!packages/osd-ui-framework/src/services/**/*/index.js',
],
moduleNameMapper: {
'@elastic/eui$': '<rootDir>/node_modules/@elastic/eui/test-env',
'@elastic/eui/lib/(.*)?': '<rootDir>/node_modules/@elastic/eui/test-env/$1',
Expand All @@ -82,7 +72,8 @@ export default {
'<rootDir>/src/dev/jest/setup/react_testing_library.js',
],
coverageDirectory: '<rootDir>/target/opensearch-dashboards-coverage/jest',
coverageReporters: ['html', 'text', 'text-summary'],
coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],
coverageReporters: ['lcov', 'text-summary'],
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
modulePathIgnorePatterns: [
'__fixtures__/',
Expand Down

0 comments on commit 878139f

Please sign in to comment.