-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
moral of the story: quote your globs on the command-line #2355
Comments
Hi @sverraest! 🙂 I’m trying to reproduce this and I seem not to be able to get there. 😳 Here is my setup:
So it looks like a runtime error causes Mocha to fail. 🤔 I’m wondering if you could share a bit of your test code, just to get a bit more context around this issue and maybe be able to reproduce and find a solution. 🤓 |
@sverraest Can you provide more context for the failure? |
I've also been observing this recently, originally I thought the issue was with protractor or gulp-protractor but I notice the issue only seems to be when the |
@unkillbob can you provide a failing test and a command line that triggers this? |
@Munter after making that observation I tried to do exactly that but couldn't reproduce it. Either its intermittent or it could be something else in the stack that's to blame - if I ever do manage to reproduce it reliably will be sure to post it here. |
I hit the same issue and spent some time to extract a reproducible case. It is a bit more complex so I put it in a quick repo: https://github.com/ibratoev/mocha-repro . |
Well, the problem is a little more complicated than this, but I'm not sure why. running |
My previous comment (which I deleted) went down the wrong path. After more tinkering, this has to do with the shell. Basically, $ ls tests/**/*.js
tests/tests/bar.js vs $ node -e "console.log(require('glob').sync('tests/**/*.js'))"
[ 'tests/tests/bar.js', 'tests/tests/tests2/foo.js' ] So, yeah. There's nothing Mocha can really do about this. You have to change your shell's behavior, or provide a string value for the glob. In Bash 4.x, you can: $ shopt -s globstar
$ ls tests/**/*.js
tests/tests/bar.js tests/tests/tests2/foo.js I don't know what the equivalent is in Bash 3.x or zsh (though I'd like to know!). Note that MacOS X ships with 3.x; use something like Homebrew to upgrade. Otherwise, this will work (and is the strategy Mocha uses in its $ mocha 'tests/**/*.js'
Test
1) Fake test
0 passing (8ms)
1 failing |
Thanks for the insight @boneskull. My scenario really has nothing to do with mocha but more with how npm works. Some related links: |
I'm using Mocha.js as part of a CI pipeline.
Recently the failing tests don't actually cause the npm test step to fail the build because it looks like Mocha.js doesn't exit in an failure state.
ERROR: {"error":{"message":"Cannot read property 'where' of undefined","stack":"TypeError: Cannot read property 'where' of undefined\n at Object.undeleted
info: Done.
npm info posttest api@0.0.0
npm info ok
This is quite annoying as it allows commits with failing tests to still be build in our CI pipeline.
The text was updated successfully, but these errors were encountered: