Istanbul: Support ignore start/ignore end comments

Created on 28 Jul 2015  路  7Comments  路  Source: gotwarlost/istanbul

We've been having some discussion on babel to add auxiliary comments around the code it generates. See issue https://github.com/babel/babel/issues/2055

This is useful for code coverage tools like those built into the lab testing library.

I know that istanbul supports ignore next, if, else and was wondering if it could support start/end?

Thanks!

Most helpful comment

I meant "since" not "sick" - damn autocorrect

All 7 comments

This is hard to do for the general case. Sick people can put start /end comments in a way that spans the AST in weird ways

I meant "since" not "sick" - damn autocorrect

@gotwarlost What do you mean? The comments don't need to be attached to the AST at all to work out what lines should be ignored, right?

@gotwarlost: +1, this would make babel +Istanbul so much better.

Although, source maps might fix the babel-Istanbul combo entirely.

483 provides a solution to this that accounts for crazy AST coverage and does not alter the existing ignore hint points.

+1, this would make babel +Istanbul so much better.

Although, source maps might fix the babel-Istanbul combo entirely.

Just curious, can anyone confirm if this is actually the case?

Will source map support in istanbul mean that _non-user, babel-generated helper code_ is ignored when reporting coverage? Meaning that we no longer need auxiliary comments at all?

Currently I use auxiliaryCommentBefore: 'istanbul ignore next' in my babel config; but since upgrading from babel 5 -> 6, this is now horribly broken (https://phabricator.babeljs.io/T2757).

As an aside, I'm keenly awaiting source map support (coming in 1.0.0, according to #212), so that I can run coverage reporting on the _final_ output of my build process (the transpiled/minified/concatenated/bundled JS that is ultimately deployed), but have the reports show the original file names/line numbers.

I have three gulp tasks for testing:

| Task | When | Invoked | Preprocessing | Coverage Reporting? |
| --- | --- | --- | --- | --- |
| test:bdd | During development | Automatically, on file change (via gulp watch) | babel | No |
| test:src | Before merging/pushing a feature branch or bug fix | Manually | babel | Yes |
| test:build | Before deployment | CI (Travis) | babel, uglify, concat | Yes |

The only reason I have both test:src and test:build is that the coverage reports for test:src are easier to read (separate coverage stats for each original file).

The reports for test:build show combined stats for the bundle (eg. app.js or bundle.js), making it harder to see exactly where coverage is missed.

I'm hoping that with source map support, I'll be able to drop test:src and just use test:build; while still retaining coverage reports that show the original file names/statistics.

If source map support _also_ removes the need to use (the now broken) auxiliaryComment{Before,After}, then that will indeed be huge improvement.

@scottohara - take a look at this stupid sample project that shows how to integrate babel and istanbul v1 for node.js

https://github.com/istanbuljs/sample-babel-node

Key ideas are:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WilliamHolmes picture WilliamHolmes  路  3Comments

parautenbach picture parautenbach  路  4Comments

lobabob picture lobabob  路  3Comments

ORESoftware picture ORESoftware  路  4Comments

ahmtcn123 picture ahmtcn123  路  3Comments