// this will find all files ending with _test.js and run them with Mocha. Put this in your package.json | |
"scripts": { | |
"test": "find ./tests -name '*_test.js' | xargs mocha -R spec" | |
}, |
This comment has been minimized.
This comment has been minimized.
It actually find the files that match the pattern in subfolders too. It works for me. |
This comment has been minimized.
This comment has been minimized.
Thank you for this trick |
This comment has been minimized.
This comment has been minimized.
Recursively running all test files in a directory with Mocha can be achieved with a packaged flag.
|
This comment has been minimized.
This comment has been minimized.
whroman +1 |
This comment has been minimized.
This comment has been minimized.
Thanks whroman |
This comment has been minimized.
This comment has been minimized.
Thanks whroman, precisely what I was looking for. |
This comment has been minimized.
This comment has been minimized.
A cross platform kitten died. |
This comment has been minimized.
This comment has been minimized.
@whroman thks |
This comment has been minimized.
This comment has been minimized.
thansk @whroman |
This comment has been minimized.
This comment has been minimized.
it works for me to wrap glob path into quotes "scripts": {
"test": "mocha \"test/**/*.spec.js\""
} |
This comment has been minimized.
This comment has been minimized.
@lxjwlt thanks mate, it works perfectly |
This comment has been minimized.
This comment has been minimized.
Does this work in windows? isnt find command for linux ? I have "test:win": "set NODE_ENV=testing&& node node_modules/mocha/bin/mocha **dont know what to replace it with here ** --reporter spec", -- Answering my own concern |
This comment has been minimized.
This comment has been minimized.
@Byloor, Near as I can tell, your solution seems to work on both Windows and *NIX systems. This is the form I used:
|
This comment has been minimized.
This comment has been minimized.
@lxjwlt, Gracias! This was the simple fix for me. Single quotes also allow you to avoid escaping.
|
This comment has been minimized.
This comment has been minimized.
Single quotes are not working for me in Windows 10.
Warning: Could not find any test files matching pattern: './**/*.spec.js'
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Also, to avoid using a pipe, you can use this version of "scripts": {
"test": "find src -name '*.spec.js' -exec mocha --require @babel/register {} \\;"
} Where:
|
This comment has been minimized.
This comment has been minimized.
In case anyone is interested, I actually switched to jest, because it seems to have a much easier test script.
That's it |
This comment has been minimized.
This comment has been minimized.
Thank you very much! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Thanks, it worked! |
This comment has been minimized.
This comment has been minimized.
anyone among you does web automation with mocha framework with java script?I cant find enough source online.I need help! |
This comment has been minimized.
This comment has been minimized.
@alitarlaaci1981 you can connect me in this regard, I use mocha with JS. |
This comment has been minimized.
By default mocha will find all .js files, this only reduce the list to _test.js files