-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Enhancement: Istanbul support #286
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
Comments
How does Istanbul handle vue? |
Try chaining the svelte loader to the babel loader with the istanbul preset. |
Another way to go is to break the logic of your component out into separate (pure JS) modules and then compose your component's exported object from those various pieces such that your component code is basically just declarative. |
@therealnicksaunders Svelte doesn't have support for that yet (#65) |
@PaulBGD I definitely should have provided an example. Here's a trivial one where a helper is implemented in a separate module in order to facilitate testing the logic.
|
@therealnicksaunders - thats fair enough for logic, but I also want to test conditional rendering of markup. |
@Swatinem Here's my original Webpack config (the relevant bits):
The above configuration works in that I can use the component with my other source code (Angular in this case) and also perform unit tests. However, when I look at the code coverage of the JS files, it does not list my component in the list of files instrumented. .babelrc:
Now when I try adding svelte-loader before babel-loader:
Output:
If I reverse the loader order:
Output:
|
looks more like karma has its own require hook or something. tbh, I have no idea how it works. |
But the above errors are Webpack compilation errors - it hasn't reached Karma yet. |
Made some progress. If I use Webpack and svelte-loader -> babel-loader, then turn off inline source maps for the .babelrc:
Output:
|
Tried using https://www.npmjs.com/package/karma-coverage-istanbul-reporter and v2.0.0 of https://github.com/deepsweet/istanbul-instrumenter-loader (which uses the newest istanbul-api) and get a similar error to before:
For me to be able to recommend Svelte as a viable option to other frameworks, the test-coverage use-case needs a solution. |
Can you try to manually compile the svelte template, and then try to manually instrument it via istanbul? Do you get the same error there as well? |
Closing to sveltejs/svelte-loader#22 |
Uh oh!
There was an error while loading. Please reload this page.
My current projects use Webpack + Karma + PhantomJS/Chrome + Istanbul to run unit tests inside a browser. It would be great if there was a way for Istanbul to "see" the JS code inside the
<script>
block in the Svelte file and add instrumentation. Or is there another way... given that I'm using Webpack, can I point Istanbul to the compiled version of the Svelte component?I should add that I can successfully unit test the component. I just can't see evidence of this because I think Istanbul is ignoring the Svelte source file (even when I direct it to include *.html files for instrumentation).
The text was updated successfully, but these errors were encountered: