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

Add Coverage To Tests #21

Open
dyoder opened this issue Jun 8, 2020 · 2 comments
Open

Add Coverage To Tests #21

dyoder opened this issue Jun 8, 2020 · 2 comments

Comments

@dyoder
Copy link
Contributor

dyoder commented Jun 8, 2020

I attempted to make some headway on this but it's a bit of rabbit hole. So here's what I've figured out.

  1. Puppeteer's coverage API doesn't yet support source maps, so we can't use that.
  2. We can instrument the webpack build by adding transpile options to coffee-loader so that it will use babel-plugin-istanbul. However, when I tried this, the build silently failed.
  3. Once the code is instrumented, we still need to pull it out of the browser environment.
  4. At that point, we can generate the output we want using nyc.
  5. Finally, we need to add a stanza to .gitignore so we don't commit the coverage reports.

The options I tried with coffee-loader look like this:

options:
  transpile:
    presets: [ [ "env", targets: "default" ] ]
    plugins: [ "istanbul" ]

which, again, just silently failed to produce an output file. (The silence is likely due to the fact that I'm not checking the response object from Webpack.)

The .gitignore stanza:

# Istanbul
coverage/
.nyc_output
@dyoder
Copy link
Contributor Author

dyoder commented Jun 8, 2020

The rationale: we're relying on scenario-based functional tests instead of unit tests (because it's difficult to test many mixins and combinators in isolation), so being able to see coverage is even more valuable than it would be otherwise. We could of course also adapt this approach for use with other projects.

@dyoder
Copy link
Contributor Author

dyoder commented Jun 8, 2020

I added error logging and this is how Webpack is failing:

CoffeeScriptError: TypeError: Cannot read property 'endsWith' of undefined

I searched for this but didn't find much. It appears to be coming from the CoffeeScript compiler, but there's nothing in the CoffeeScript code that uses that. And, of course, it compiles fine without the use of Babel. So it's probably related to Babel, but I didn't test any farther than that.

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

No branches or pull requests

1 participant