{"id":8062,"date":"2015-11-23T18:32:52","date_gmt":"2015-11-23T18:32:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/23\/how-to-specify-test-directory-for-mocha-open-source-projects-mochajs-mocha\/"},"modified":"2022-08-30T15:03:02","modified_gmt":"2022-08-30T15:03:02","slug":"how-to-specify-test-directory-for-mocha-open-source-projects-mochajs-mocha","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/23\/how-to-specify-test-directory-for-mocha-open-source-projects-mochajs-mocha\/","title":{"rendered":"How to specify test directory for mocha?-open source projects mochajs\/mocha"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0d9d9ba199e47495f331847c00afb546?s=128&amp;d=identicon&amp;r=PG\" \/> <strong>Robin Luiten<\/strong><\/p>\n<p>I am on Windows 7 using node.js v0.10.0 and mocha v1.8.2 and npm v1.2.14. I was just trying to get mocha to use the path test\/unit to find my tests, After spending to long and trying several things I landed,<\/p>\n<p>Using the &#8220;test\/unit\/*.js&#8221; option does not work on windows. For good reasons that windows shell doesn&#8217;t expand wildcards like unixen.<\/p>\n<p>However using &#8220;test\/unit&#8221; does work, without the file pattern. eg. &#8220;mocha test\/unit&#8221; runs all files found in test\/unit folder.<\/p>\n<p>This only still runs one folder files as tests but you can pass multiple directory names as parameters.<\/p>\n<p>Also to run a single test file you can specify the full path and filename. eg. &#8220;mocha test\/unit\/mytest1.js&#8221;<\/p>\n<p>I actually setup in package.json for npm &#8220;scripts&#8221;: { &#8220;test&#8221;: &#8220;mocha test\/unit&#8221; },<\/p>\n<p>So that &#8216;npm test&#8217; runs my unit tests.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Robin Luiten I am on Windows 7 using node.js v0.10.0 and mocha v1.8.2 and npm v1.2.14. I was just trying to get mocha to use the path test\/unit to find my tests, After spending to long and trying several things I landed, Using the &#8220;test\/unit\/*.js&#8221; option does not work on windows. For good reasons that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8062","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8062"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8062\/revisions"}],"predecessor-version":[{"id":8656,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8062\/revisions\/8656"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}