jspm / registry

The jspm registry and package.json override service
https://jspm.io
229 stars 256 forks source link

Mocha overrides #1033

Open adelespinasse opened 7 years ago

adelespinasse commented 7 years ago

The overrides file for Mocha includes

    "diff": "@empty",

which I think is probably why it behaves strangely when a test fails:

err  TypeError: diff.createPatch is not a function
    at unifiedDiff (file:///C:/Users/aldel/agora/playdoh/public/jspm_packages/npm/mocha@3.2.0/lib/reporters/base.js:417:18)
    at file:///C:/Users/aldel/agora/playdoh/public/jspm_packages/npm/mocha@3.2.0/lib/reporters/base.js:218:16
...

Mocha is trying to use diff to format its output for the failure (I assume), but diff is empty because of the override. Is this override needed for something?

adelespinasse commented 7 years ago

I got it to behave correctly by removing the override (directly editing the override in my package.json) and installing diff with jspm install --dev npm:diff. No idea why that override exists.

I don't have enough confidence about jspm configuration to submit a pull request.

aluanhaddad commented 7 years ago

See also #1022.

adelespinasse commented 7 years ago

Oh, I later noticed that this is a problem with the exceptions thrown by Chai, but not by Unexpected, and not if the test simply does something like throw new Error('error'). Possibly this is why @guybedford didn't notice the issue when writing the Mocha overrides and/or this article. I guess Mocha has special handling for Chai's exceptions.

aluanhaddad commented 7 years ago

Honestly I know little about test frameworks such as mocha, chai, and sinon. Instead I use tape + jspm run test/index whenever I can because I like for to test frameworks to be simple and I dislike when they encourage mutating steps.

Thanks for linking that article here, it is indeed a great read and was a pleasure to read again.