0

I added ember-cli-blanket into my project and managed to get it working fine. localhost:4200/tests?coverage would show the coverage data. However it included files such as 'project/components/modal-dialog' or 'project/components/modal-dialog-overlay' in the results, which are not files in the project, but are included by Ember since the project uses a modal dialog in one of the template files. These extra test files don't give me anything new since I'm not testing the ember codebase and actually muddle the results by mixing in my tests with other ones. The project is still small, and with ~11 actual files needing testing, there were around 12 files I had to add to the loaderExclusions in blanket-options.js. Some could be gotten rid of with an exclusion like:

loaderExclusions: ['project/initializers'],

But for the ones under project/components, I do want to test the components that are part of the project, so I had to exclude each one individually. And there's no guarantee that excluding all initializers files won't come back to bite me if I actually end up with any files in there I want to test. Considering how small the project is so far, and the fact that there are more exclusions than actual files, this doesn't seem like a sustainable solution.

Am I doing something wrong in my set-up? Is this something I can solve with my filter which is currently on a default of:

filter: '/.*project/.*/',

Any help would be appreciated.

As a sidenote, I've been looking into testem with Istanbul as well as Karma as other options for coverage data in Ember but have been unable to get anywhere with them. If you have suggestions on the setup for those that would also be fine.

gdavdov
  • 153
  • 1
  • 6

2 Answers2

1

It doesn't look like there's anything wrong with your setup. What you're seeing is apparently due to how blanket.js works. See this issue for more information: https://github.com/sglanzer/ember-cli-blanket/issues/17

Patrick Berkeley
  • 2,206
  • 21
  • 26
  • I'd read through the thread, but it seemed to be referencing addons specifically, whereas this is code already in ember (I thought, I never specifically installed it as far as I remember). It may be the same issue at its core, though. I noticed the suggestion of a whitelist working betting than a blacklist (still more upkeep than it should be in my opinion, but better than a blacklist of unknown adds), but am unsure how to go about that. Is it basically a really long filter with each file on its own in the regex? – gdavdov Feb 04 '16 at 14:27
  • The files you listed `project/components/modal-dialog` and `project/components/modal-dialog-overlay` are exposed in your application via the modal-dialog addon, which is why they're getting picked up when you run blanket on your app. – Patrick Berkeley Feb 04 '16 at 17:39
  • You might be able to do something with a regex, but I'm guessing it would be easier and more readable to just list each file out. It shouldn't be too much of a burden since it's a one-time setup. – Patrick Berkeley Feb 04 '16 at 17:40
  • Good call on the modal-dialog ones, sorry...but it was also including 'project/controllers/array' and 'project/controllers/object', which shouldn't be add-ons. For your last suggestion, I'm not sure I'm following. Do you agree with the whitelist idea, or are you thinking the blacklist under loaderExclusions is the way to go? If it is the whitelist, I agree I shouldn't be trying to create a regex to describe all the files, but I'm not sure how to list them out. Do I convert the default regex 'filter' option into an array of filenames? Is it a different option in blanket-options.js? – gdavdov Feb 04 '16 at 20:54
  • I was thinking `loaderExclusions` seemed like a solid way of handling it, but I'd need to set it up and try it out to see if that actually worked well. – Patrick Berkeley Feb 05 '16 at 03:28
  • Blacklisting using loaderExlusions is very possible, and I can post an example of how I got that working if desired. But...because the files for blacklisting are a bit of an unknown due to ember adding in some of its own files, I also worked out a way to whitelist...which was basically a really epic regex where each folder (or file if necessary) was matched individually in the filter, which I can also show. Neither way is particularly elegant, and both require upkeep, but now I can manage the files included so that only ones we actually created show up. – gdavdov Feb 05 '16 at 16:39
  • Seems reasonable! From what I've seen there's not a more elegant way of doing it. – Patrick Berkeley Feb 06 '16 at 05:08
1

I was using ember-cli-blanket then found ember-cli-code-coverage. As of this writing, the sandersky fork, at 9f1dd33f, works great for me to solve the type of problem you're describing.

https://github.com/kategengler/ember-cli-code-coverage/pull/11

It solves it not using blanket, but using istanbul.

patcoll
  • 966
  • 6
  • 8
  • Just a followup on my previous answer, to say that this functionality was merged into and released from the canonical repo, at either version 0.2.1 or 0.2.2. – patcoll Jul 28 '16 at 20:50