Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGeoffrey Neal
30,298 PointsAdvanced file structure for testing
In the video Guil talks about the "test" folder, I've set it up and it all works great. But it seems that ALL your test files need to go in that one folder i.e: You can't have any sub-directories otherwise when you run mocha or npm test, it doesn't seem to work properly.
I've tried running things like mocha ./test/* but with varying results.
This wouldn't bother me so much except in a larger project, I want to build a testing file structure that mimics my application logic file structure. For example, if I have a folder called "app" that contains a sub-directory called "controllers" with a file called "someCtrl.js", but there is another sub-directory called "directives" with a file called "someDirective.js"
app > controllers > someCtrl.js
and
app > directives > someDirective.js
I would then want to create the same file structure so that my test files are in the same format e.g:
test > app > controllers > someCtrl_test.js
and
test > app > directives > someDirective_test.js
Is there a standardised way of creating a more in depth file structure for testing purposes? Or is this bad practise?
Thanks in advance
1 Answer
Seth Kroger
56,414 PointsUse mocha --recursive
Geoffrey Neal
30,298 PointsGeoffrey Neal
30,298 PointsWorks perfectly! Thanks Seth.