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

Rewrite custom require hook & source map tests #73

Merged
merged 3 commits into from
Dec 6, 2015

Conversation

novemberborn
Copy link
Contributor

This is a rewrite of the source map tests so I can add the test coverage required in #66. This necessitated replacing the Babel test with a better one for generic custom require hooks.

This uses a new npm package named source-map-fixtures. It provides a few source files with different source map variants, making it easier to generate fixtures. I'm planning on updating the source map tests in AVA as well.

I've solved the problem of generating coverage reports for testing by adding a _generateCoverage script in test/fixtures. It generates a report for the source map fixtures.

And finally I've excluded the two tests from the coverage report. Seemed silly to get missing test coverage for the tests…

@bcoe
Copy link
Member

bcoe commented Dec 4, 2015

\o/ this is looking great, and is very much appreciated. let me know when you need a thorough review.

Use a spy to verify custom require hooks are wrapped correctly. Remove the more
complicated test using babel-register and clean up dependencies. Stop sharing an
nyc instance between the wrap tests.
Use source-map-fixtures to get a fixture file with an inline source map. Add a
script to generate a coverage report for this specific fixture. Rewrite tests to
use the fixture, without (too much) hardcoding of values.

This will make it easier to upgrade the fixture in the future, as well as
regenerate the coverage report.
@novemberborn novemberborn changed the title wip! Rewrite source map tests Rewrite custom require hook & source map tests Dec 6, 2015
@novemberborn
Copy link
Contributor Author

@bcoe I'm finished with this now, thanks.

// Write the coverage file so reports can be loaded.
nyc.writeCoverageFile()

var reports = _.values(nyc._loadReports()[0])
Copy link
Member

Choose a reason for hiding this comment

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

this is a great approach for generating the fixtures, and I love the module source-map-fixtures.

@bcoe
Copy link
Member

bcoe commented Dec 6, 2015

The tests run way faster without the babel step, this is great.

bcoe added a commit that referenced this pull request Dec 6, 2015
Rewrite custom require hook & source map tests
@bcoe bcoe merged commit 361ad44 into istanbuljs:master Dec 6, 2015
bcoe pushed a commit that referenced this pull request Dec 6, 2015
bcoe added a commit that referenced this pull request Dec 6, 2015
the combination of #73 and #66 broke tests on master
@novemberborn novemberborn deleted the rewrite-source-map-tests branch December 7, 2015 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants