-
Notifications
You must be signed in to change notification settings - Fork 9
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
Not working with Karma #5
Comments
Ahh... this has always been a perenial problem with getting it to work with mocha runners. I think it's time to document the workaround. |
I've written a rudamentary guide here: Let me know if that works for you. |
...either that, or try: client: {
args: [ '--require', 'mocha-clean' ]
}, let me know which one works, then I'll update the docs properly for everyone's benefit. |
...also do try the |
Well I tried. Turns out that Thanks anyway. I'm happy to see it working in the browser, and I think I'll leave it at that. |
i tried the workarounds too, but it seems it only works in the browser. not with gulp nor karma (nor gulp running karma) |
also not working, test repo here:
noting that karma-mocha actually doesn't really support client args other than grep |
screw it, problem solved by making a new reporter: I'm using your module's exported function to format the stack before output https://github.com/davidosomething/karma-mocha-clean-reporter/blob/master/index.js#L167 |
thanks! however, mocha-clean should now be considered deprecated considering mocha 2.2.5 now has mocha-clean in it by default :) |
Good info, maybe update the readme? |
How do you enable |
@rstacruz Could you share your approach please? :) |
Okay, mocha-clean isn't deprecated anymore—mocha has since reverted the mocha-clean patch into mocha. Honestly don't know any other method than what's listed here — unfortunately as reported here, they don't really work. :\ |
I see, thanks for looking into it! |
I've opened karma-runner/karma#2313 to solve this in Karma core. Turning this stack:
Into this:
|
Hello, what is the solution for this as of today? I still get huge error stack traces which make no sense when running a test. |
I've finished adding the Example usage in Semantic-UI-React can be seen here. In short, you get to filter each line of the stack, return an empty string to filter the line out. Return a string followed by a new line character to retain it. Obviously, you can also edit the line before returning it. |
Wow thank you, very fast response. I'll check your example :-) |
Got it working! Here's the final code I used that worked, in case anyone else stumbles accross this and needs help: // karma.config.js
formatError(msg) {
// Uncommment this to get rid of the entire stack trace, but then you don't know what happened
// return ''
// filter out empty lines and node_modules
if (!msg.trim() || /~/.test(msg) || /node_modules/.test(msg)) return ''
// indent the error beneath the it() message
let newLine = ` ${msg}`
if (newLine.includes('webpack:///')) {
// remove webpack:///
newLine = newLine.replace('webpack:///', '')
// remove bundle location, showing only the source location
newLine = newLine.slice(0, newLine.indexOf(' <- '))
}
return `${newLine}\n`
}, |
I don't normally start a bug report by praising the author, but I love your module when I run tests in the browser! :)
I love it a little less when I use Karma, though. Didn't get it to work.
I tried two different modifications in karma.conf.js, as suggested in the karma-mocha docs. The first,
didn't actually clean up anything which wasn't clean already, and
got me a
TypeError: 'undefined' is not a function (evaluating 'this[opt](opts[opt])')
.All modules are at their latest version, except for Mocha, which I have kept on the 1.x branch so far (1.21.5).
Any ideas how I can get it to work?
Thanks,
Michael
The text was updated successfully, but these errors were encountered: