Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Make coverage reports es6 #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

magicmark
Copy link
Contributor

  • Switched to nyc from istanbul
  • Moved coverage report levels (need to investigate why they dropped in some cases)
  • Changed some test imports to import from src rather than lib

(Used to look like this, now they look like this

test:quick and tests-only are kinda useless now but unsure if safe to deprecate (major bump?)

@ljharb
Copy link
Collaborator

ljharb commented Apr 13, 2017

nyc has more accurate coverage than istanbul-cli, so it's ok if they dropped a little bit.

package.json Outdated
"test:quick": "babel-node node_modules/.bin/_mocha -R tap test/init.js test/*-test.js"
"test": "npm run test:coverage && npm run --silent cover:check",
"tests-only": "npm run test:quick",
"test:coverage": "nyc --silent node_modules/.bin/_mocha -R tap test/init.js test/*-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.

while we're at it, can this just use mocha directly, instead of needing the _mocha istanbul hack?

server.js Outdated
@@ -1 +1 @@
module.exports = require('./lib/server.js');
module.exports = require('./src/server.js');
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will break the package. Please revert it.

@@ -2,7 +2,7 @@ import { assert } from 'chai';
import sinon from 'sinon-sandbox';

import { makeJob, COMPONENT_NAME } from './helper';
import BatchManager from '../lib/utils/BatchManager';
import BatchManager from '../src/utils/BatchManager';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly, we actually want tests to be run on babel output; not on the raw source.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we can have source maps, even when we're running tests on the babel output. I've set this up with nyc in another package.

@magicmark
Copy link
Contributor Author

magicmark commented May 27, 2017

@ljharb rebased + made changes. I guess babel-node isn't needed since nyc is using babel-register to transpile tests.

Copy link
Collaborator

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Thanks, this is almost ready!

package.json Outdated
"test:quick": "babel-node node_modules/.bin/_mocha -R tap test/init.js test/*-test.js"
"test:coverage": "nyc --silent node_modules/.bin/mocha -R tap test/init.js test/*-test.js",
"cover:check": "nyc report && echo code coverage thresholds met, achievement unlocked!",
"test:quick": "npm run test:coverage"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the point of the "quick" script is to run without coverage :-) can this line be reverted?

.nycrc Outdated
@@ -0,0 +1,17 @@
{
"lines": 91,
"functions": 56,
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I ran this locally on node 7, it failed with 55.something - could we drop this to 55 just to avoid the failure later, when I add node 7 to travis?

- Switch to nyc
- Update thresholds
@magicmark
Copy link
Contributor Author

@ljharb rebased again

passing with node 6 and 7:

v6.3.1:
=============================== Coverage summary ===============================
Statements   : 91.06% ( 163/179 )
Branches     : 70.31% ( 45/64 )
Functions    : 57.89% ( 44/76 )
Lines        : 90.8% ( 158/174 )
================================================================================

v7.7.3:
=============================== Coverage summary ===============================
Statements   : 91.06% ( 163/179 )
Branches     : 70.31% ( 45/64 )
Functions    : 56.58% ( 43/76 )
Lines        : 90.8% ( 158/174 )
================================================================================

@@ -5,13 +5,13 @@
"main": "lib/index.js",
"scripts": {
"prepublish": "not-in-publish || safe-publish-latest && npm run build",
"build": "rimraf lib && babel src -d lib",
"build": "rimraf lib && babel --source-maps inline src -d lib",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid using inline source maps, and use regular ones instead?

Copy link
Contributor Author

@magicmark magicmark Jul 6, 2017

Choose a reason for hiding this comment

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

Hmm, running into some problems here.

The higher quality source maps decreases the coverage which isn't a big deal (I guess this was the point :D), but I can't get nyc to map back to original sources.

I tried both with and without the babel-plugin-istanbul plugin, with every combination of sourceMap, instrument and env vars, but I couldn't get the mapping back from the instrumentation code+es5/es5 respectively :(

I can't find anything in the nyc or babel-plugin-istanbul docs about external source maps - I also notice the documentation seems to recommend using inline source maps (https://github.com/istanbuljs/nyc#support-for-custom-require-hooks-babel-webpack-etc)

I'll open an issue+reproducible example on nyc later, but for now, this is blocking me :(

Have you got any thoughts w/r solving this? (You mentioned you had another repo set up with nyc?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/airbnb/prop-types/blob/master/package.json#L52 is the other repo.

I'm not sure how to set it up.

It would be fine to build with inline source maps only when building for coverage, it just means we have to build twice.

"lint": "eslint src test",
"pretest": "npm run --silent lint",
"test": "npm run build && npm run test:coverage && npm run --silent cover:check",
"tests-only": "npm run build && npm run test:quick",
"test:coverage": "babel-node node_modules/.bin/istanbul cover --report html node_modules/.bin/_mocha -- -R tap test/init.js test/*-test.js",
"cover:check": "istanbul check-coverage && echo code coverage thresholds met, achievement unlocked!",
"test:coverage": "nyc --silent node_modules/.bin/mocha -R tap test/init.js test/*-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.

can we use nyc --silent "$(which mocha)" … rather than hardcoding node_modules?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants