@
@
@Richswitch2018-01-07 19:23:03
JavaScript
@Richswitch, 2018-01-07 19:23:03

Why does Mocha require a times-loop for complex file testing?

Hey!
I want to test files in all directories using the command mocha ../**/*.test.js. I get an error in the console

> [email protected] test-module /home/richard/Documents/dev/server/test
> mocha ../**/*.test.js

module.js:544
    throw err;
    ^

Error: Cannot find module 'times-loop'                                     ---> ????????
    at Function.Module._resolveFilename (module.js:542:15)
    at Function.Module._load (module.js:472:25)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/richard/Documents/dev/server/test/node_modules/assert-err/test/assert-err.test.js:5:13)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at /home/richard/Documents/dev/server/test/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/home/richard/Documents/dev/server/test/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/home/richard/Documents/dev/server/test/node_modules/mocha/lib/mocha.js:536:10)
    at Object.<anonymous> (/home/richard/Documents/dev/server/test/node_modules/mocha/bin/_mocha:573:18)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Function.Module.runMain (module.js:682:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:613:3

But if you check 1 file at a time , for example with the command mocha ../graphql/index.test.js, then everything will work.
Tested file (don't pay attention to assert):
5a524aff28ba9793790983.png
Question:
Why does Mocha require times-loop when complex testing files?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Popov, 2018-01-08
@DjPhoeniX

In the stack trace of the error, it is quite clear that the pattern "../**/*.test.js" contains the file ".../dev/server/test/ node_modules /assert-err/test/assert-err .test .js ". Which is part of another module, and most likely has its own dependencies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question