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

tests: fix coverage generation #7475

Merged
merged 3 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ npm-debug.log
coverage
lcov.info
.nyc_output
*.lcov

lighthouse-cli/results
results.html
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ latest.artifacts.log
npm-debug.log
yarn-error.log
results.html
*.lcov

# dev files
.appveyor.yml
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ script:
- yarn bundlesize
- yarn diff:sample-json
- yarn lint
- yarn unit:silentcoverage
- yarn unit:cicoverage
- yarn type-check
- yarn smoke:silentcoverage
- yarn smoke:cicoverage
- yarn test-clients
- yarn test-viewer
- yarn test-lantern
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
collectCoverageFrom: [
'**/lighthouse-core/**/*.js',
'**/lighthouse-cli/**/*.js',
'**/lighthouse-viewer/**/*.js',
'!**/test/',
'!**/scripts/',
],
Expand Down
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@
"test-viewer": "yarn unit-viewer && jest lighthouse-viewer/test/viewer-test-pptr.js",
"test-lantern": "bash lighthouse-core/scripts/test-lantern.sh",
"unit-core": "jest \"lighthouse-core/\"",
"unit-core:ci": "jest --runInBand --coverage --ci \"lighthouse-core/\"",
"unit-cli": "jest --runInBand \"lighthouse-cli/\"",
"unit-cli:ci": "jest --runInBand --coverage --ci \"lighthouse-cli/\"",
"unit-viewer": "jest \"lighthouse-viewer/\"",
"unit-cli": "jest \"lighthouse-cli/\"",
"unit-viewer": "jest lighthouse-viewer/**/*-test.js",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this bringing in too many things the old way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this bringing in too many things the old way?

yeah, when we switched the viewer puppeteer test from mocha to jest, that meant the looser jest lighthouse-viewer/ was running that test as a unit test which seems wrong and doesn't help coverage anyways because it runs against the built viewer in dist/, not the original source files.

Maybe the puppeteer tests should live somewhere else?

"unit": "yarn unit-core && yarn unit-cli && yarn unit-viewer",
"unit:ci": "yarn unit-core:ci && yarn unit-cli:ci && yarn unit-viewer",
"unit:ci": "npm run unit-core -- --runInBand --ci --coverage && npm run unit-cli -- --runInBand --ci --coverage && npm run unit-viewer -- --runInBand --ci --coverage",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a fun line to read :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a fun line to read :)

ha, happy for ideas on how to make it more readable :)

"core-unit": "yarn unit-core",
"cli-unit": "yarn unit-cli",
"viewer-unit": "yarn unit-viewer",
"watch": "yarn unit-core --watch",
"unit:silentcoverage": "nyc --silent yarn unit:ci && nyc report --reporter text-lcov > unit-coverage.lcov",
"coverage": "nyc yarn unit:ci && nyc report --reporter html",
"smoke:silentcoverage": "nyc --silent yarn smoke && nyc report --reporter text-lcov > smoke-coverage.lcov",
"coverage:smoke": "nyc yarn smoke && nyc report --reporter html",
"unit:cicoverage": "nyc --all --hook-run-in-context npm run unit:ci && nyc report --reporter text-lcov > unit-coverage.lcov",
"coverage": "yarn unit:cicoverage && nyc report --reporter html",
"smoke:cicoverage": "nyc npm run smoke && nyc report --reporter text-lcov > smoke-coverage.lcov",
"coverage:smoke": "yarn smoke:cicoverage && nyc report --reporter html",
"coveralls": "cat unit-coverage.lcov | coveralls",
"codecov": "codecov -f unit-coverage.lcov -F unit && codecov -f smoke-coverage.lcov -F smoke",
"devtools": "bash lighthouse-core/scripts/roll-to-devtools.sh",
Expand Down Expand Up @@ -186,14 +184,18 @@
],
"nyc": {
"reporter": [
"lcov",
"text"
"text-summary"
],
"tempDirectory": "./coverage",
"include": [
"**/lighthouse-core/**/*.js",
"**/lighthouse-cli/**/*.js",
"**/lighthouse-viewer/**/*.js"
],
"exclude": [
"**/third_party/**",
"**/test/",
"clients/"
"**/scripts/"
]
},
"homepage": "https://github.com/GoogleChrome/lighthouse#readme",
Expand Down