-
Notifications
You must be signed in to change notification settings - Fork 2
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
Native test coverage beta candidadte #7
Conversation
Oh nice, looks like you found a workaround for the problem where nothing was running after jasmine.execute(). I'll still look into that just for my own curiosity, and I'll also pull down these changes and see how they work for me. |
Deff, and please share your findings if you solve the mystery. I needed a workaround like that either way since jasmine.execute() appears to be asynchronous. By the way, I'm using this as my app script:
|
@m-a-r-c-e-l-i-n-o looks great! Of the two projects that I tested, one of them generated coverage reports right out of the box! The other one I was able to track down the problem pretty quickly --
I'm not totally sure why JSPM didn't create a source map for this file, but maybe because it's so simple that the transpilation step didn't alter the file enough to warrant a sourcemap?? That's just a guess though. I was able to solve the problem by being a little more defensive in the System.instantiate hook (see my other comment on that specific line). Regarding your other question, I believe the |
// Start source map processing | ||
// all of this could be avoided if we come to a resolution | ||
// on this: https://github.com/SitePen/remap-istanbul/issues/48 | ||
delete load.metadata.sourceMap.sourcesContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load.metadata.sourceMap
is not always defined. I'm not totally sure why (see my other comment for my guesses), but how do you think we should handle those cases? Perhaps just skip files where systemjs does not generate a source map? Or maybe assume that it means that the source file itself should be referenced as the source map file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just about to reply to your other comment, trying to keep up, lol. So here's what I was saying...
I had some doubts about the load.metadata.sourcemap because jspm only transpiles when it needs to, but then I reasoned that you have to export something if you are to test it, and if you export you must be using ES6, therefore there must always be a source map. With that in mind, notice how you had an issue with a file that has no exports, but also notice how that file should not be getting covered! LOL. Actual test files should not get covered, only app files, thus the option for defining your app files coverageFiles: ["src/shared/**/*.js"]
. Instead of accommodating, we should reject these files. Not sure what the best approach is, but maybe we should just let it throw errors for files without sourcemaps, because it likely shouldn't be getting covered anyway and prompt the user to exclude them with the coverageFiles
option. But this leaves me with a lingering feeling that maybe there are files that should be covered but don't have source map. I just can't think of any. Can you think of a file that is not a test file, but that can be tested, and that does not export anything therefore would not get transpiled with a source map?
Maybe we can only process files with exports (and thus have sourcemap), and have another option where the user can define exception files (if they even exist)? Or not provide an exception option, wait for a user to complain, and go from there...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are plenty of people who use JSPM for files that are not ES6 modules (amd modules, umd modules, commonjs modules, typescript, or even just globals etc). Those modules have things that can be tested because they either export things (just not with the export
keyword) or they expose globals that can be tested. In the case of amd, umd, globals, and commonjs, the files might not be transpiled but SystemJS just provides them a require
function, a define
function, etc.
Regarding what we should do in these cases, could we potentially just instrument the file with Istanbul, without having a source map that will be remapped? I'm not sure if remap-istanbul is okay with some files not having source maps, but my guess is that it would be fine??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=O okay, so there's a lot more that should be allowed than I thought. My biggest concern is just not letting a bunch of depedencies go through the coverage system. But yeah, would have to bypass "remap-istambul", not a big deal. Should be straightforward.
EDIT: On second thought, this is a little more involved, "remap-istambul" does care. I might have to go as far as mocking the source maps for files without any, was not thinking in terms of "batch mode" when I said "Should be straightforward". I'll get it done by tomorrow. Lmk what you want to do about my other comment so I can submit an update with all the changes.
Also, here's a list of some other things I think we could fine tune with coverage. If you'd prefer we could address these things after merging this pr in, or we could do it as part of this pr. Your call.
Like I said, your call on if we want to do these things as separate pull requests or not. |
Awesome about the It's up to you on the pr update, I would say we update this pr request to address all things not having to do with the CLI interface. Then do a separate one for that.
|
I like that plan -- we'll do the cli portion afterwards.
{
// presence of the `coverage` property means that you want coverage. No need to put "coverage": true.
coverage: {
dir: 'coverage',
files: 'src/**/*.js',
// The text and text-summary reporters would *always* used
reporter: 'html', // html is the only reporter we would start with support for
}
}
|
Oh also, as I thought about it more, I'm not totally sure if the |
0130b9f
to
1e48fd3
Compare
Okay, I've updated the pr. Couple of things to note:
So yeah, that pretty much covers all our concerns for now, let me know if I missed something. |
@m-a-r-c-e-l-i-n-o Thanks for all the help with this! There are still some things to do with it, but this is a great start. I'll publish a new version of node-jspm-jasmine now, and then hopefully have time today to follow up with some improvements. |
Published as 2.1.0 |
@joeldenning Issues #8, #9, and #10 are trivial, let me know if you want me to take care of them. Would love a description of #11 for curiosity sake, and could potentially take care of it too (maybe the robust solution I hinted previously would be necessary). Issues #12 and #13 are simple, here if you need me. Lastly, can I get your confirmation to keep the temp file strategy (to avoid memory issues) and close this request? |
@m-a-r-c-e-l-i-n-o I'm currently working on #8, #9, #13, and #14. But feel free to pick off any of the other ones. Also, I'll add some more detail to #11. Regarding your other question, I'm fine with sticking with the temp file strategy. One thing with that, though, is that we'll have to make very sure that those files are deleted under all circumstances. |
@joeldenning I can take care of #10 and I can look into #11 when you post more info. I'll leave #12 to you since it's along the same vein as #13. I'm going to open an issue for making sure that the temp files are deleted under all circumstances. |
Ironed out most of the issues discussed here. I think we're pretty close to a working release, just seeing if maybe we can get rid of the need for physical files. For the time being, please test this pull request on your system(s), I'm not feeling too confident about my simplistic normalization of the "file://" paths. It might fail on Windows or Mac... Not sure. Also had to create two more options (JS Api only, for now). Here's what my calling script looks like: