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
Unable to reproduce coverage #305
Comments
@kdex what platform are you running on, OSX? |
@kdex I was able to get things working partially by using nyc@next directly: "nyc": {
"include": [
"src/**/*.js"
],
"exclude": [
"**/test/**/*",
"packages/**/*"
],
"sourceMap": true,
"instrument": true,
"require": [
"babel-register"
],
"all": false
} rather than using @jamestalmage anything jump out at you? |
Did a bit more investigation, I'm actually unable to run tests on my machine due to the error: Error: Cannot find module '/Users/benjamincoe/bcoe/coverage/map-game/dist/client/js/cache.js' But ultimately, I think the path that gets passed to
which doesn't get instrumented, because I think there's some work we need to do around the various interactions between: test-exclude, nyc, ava, and babel-plugin-istanbul. Having said this, give things a spin using |
I haven't the slightest idea why this would be happening, but I would not be surprised to find out that |
// @dak |
The loader is easy to debug if you're thinking it's at fault. Try "AVA_JSPM_LOADER_DEBUG=1 ava" and see if any of the output that occurs right before the exception looks suspicious. |
@jamestalmage it's worth noting that ava-jspm-loader does not apply any transforms to the code. It creates a small (<100 line) wrapper around Module._load that tries to look up a module in the SystemJS project registry before forwarding it on to the normal Node module loader. If babel-plugin-istanbul is dependent on some sort of module loading behavior that works with Node but not with JSPM (e.g.; directly importing nested dependencies is not possible because SystemJS doesn't map them) then ava-jspm-loader will expose that bug. But it's not a bug in ava-jspm-loader per se. For example: fluffywaffles/ava-jspm-loader#3 is caused by the aforementioned nested dependency resolution glitch. You cannot |
In other words: this is more likely a istanbul + jspm/systemjs interop bug than something to do with ava-jspm-loader directly. But I could be wrong. |
Can you still |
Hmm. I get an entirely different error from @bcoe
It originates from this line. That's obviously not a good path into Here is the output from
|
Nested modules isn't the problem. If you directly install fbjs via jspm, like After transpilation, all imports => requires - and ava-jspm-loader intercepts calls to require and tries to load using SystemJS. If SystemJS says, "no, I don't have one of those," it forwards the module name on to the Node Module loader. (Basically.) This is the situation that doesn't work:
|
@jamestalmage Your paths don't always go into SystemJS clearly thinks you have installed |
Essentially the entire job of ava-jspm-loader is just redirecting certain imports to jspm_packages instead of node_modules. |
I hadn't run |
Just think of it as an alternative to npm. SystemJS, then, is like... well, a universal module loader. It loads modules, transpiles them, supports AMD-style paths, etc, etc etc. So really JSPM is two things: 1) an alternative to npm and 2) a CLI for SystemJS so that you can build, bundle, configure, and so on from the terminal. :) You can also read the sales pitch at http://jspm.io. It's fairly informative. |
So, I was able to generate coverage using the following steps:
That we are requiring from diff --git a/jspm.config.js b/jspm.config.js
index 02633c1..ae5678c 100644
--- a/jspm.config.js
+++ b/jspm.config.js
@@ -2,8 +2,8 @@ SystemJS.config({
paths: {
"npm:": "packages/npm/",
"github:": "packages/github/",
- "server/": "dist/server/js/",
- "client/": "dist/client/js/"
+ "server/": "src/server/js/",
+ "client/": "src/client/js/"
},
browserConfig: {
"baseURL": "/<%LINUX_USERNAME%>" I deleted the
The tests pass, but I still get no coverage. I finally hunted it down to AVA's The default Manually hacking // node_modules/babel-plugin-istanbul/lib/index.js
function shouldSkip(file) {
if (!exclude) {
exclude = testExclude({
- cwd: getRealpath(process.cwd()),
+ cwd: process.env.NYC_CWD || getRealpath(process.cwd()),
configKey: 'nyc',
configPath: (0, _path.dirname)(findUp.sync('package.json'))
});
}
return !exclude.shouldInstrument(file);
} |
@skorlir @sindresorhus @novemberborn @bcoe @novemberborn |
@jamestalmage common practice only if you're using TypeScript, in my experience. The point of the loader is indeed to avoid having a pre-build step. I wrote the recipe with the intention that it would encourage people to not prebuild before testing. In fact, I've not seen a setup before that creates a I'd almost prefer to not mention building in the recipe, seeing as if you're building to a bundle ahead of time it defeats the purpose of having a loader in the first place. |
Yes, agreed. But if you're using JSPM you're almost certainly targeting the browser, and you will build at some point before pushing to the server / cdn. I am wondering if we can't somehow make it clearer what the loader is capable of, and how it eliminates the prebuild step for testing. |
Would it be sufficient to just say, during the preamble of the loader recipe, "The loader exists so that you don't have to build before running your unit tests"? |
@jamestalmage I'm comfortable with the |
@kdex as I understand it, one would ordinarily use |
@kdex I've published a new version of I'm also about to publish |
@jamestalmage We really do... It's stuck needing a codemod. It's already labeled as priority. |
See istanbuljs/nyc#305 - specifically [this comment and the one after it](istanbuljs/nyc#305 (comment)). Essentially, @jamestalmage brought up that it would be good to explicitly mention in the recipe that you should not pre-build your project with JSPM/SystemJS to run your tests. The purpose of ava-jspm-loader is that you do not have to build before testing. Closes #954
See istanbuljs/nyc#305 - specifically [this comment and the one after it](istanbuljs/nyc#305 (comment)). Essentially, @jamestalmage brought up that it would be good to explicitly mention in the recipe that you should not pre-build your project with JSPM/SystemJS to run your tests. The purpose of ava-jspm-loader is that you do not have to build before testing. Closes #954
The text was updated successfully, but these errors were encountered: