node.js - Keep Mocha tests alongside source files -
i have nodejs source files in src
, test suites in test
, e.g.:
/src/bar/baz/foo.js /test/bar/baz/foo.spec.js
this leads awkward require statements var foo = require('../../../src/bar/baz/foo')
. , it's hard see @ glance source files missing tests. instead keep test suites in same directory relevant source files:
/src/bar/baz/foo.js /src/bar/baz/foo.spec.js
but running mocha --recursive src
causes errors mocha tries run source files tests.
i've seen suggestions of using find
or gulp
filter file list find surprising can't done plain mocha. what's recommended way of organising files way?
just pass pattern of test files mocha, like:
mocha "src/**/*.spec.js"
this going run .spec.js
files in subdirectories of src
.
Comments
Post a Comment