2

When using the --recursive flag with mocha, what is the best method to ignore subdirectories within test/?

As an example, I have a test/x, test/y, test/z directory containing tests, more of which can be added and removed all the time (so maintaining a whitelist would be tedious). I also have test/utilities and test/integration which contain code I don't want executed by mocha.

Thomas Hunter II
  • 5,081
  • 7
  • 35
  • 54

1 Answers1

2

I used a slightly modified version of this answer to find the script directories.

Since you're using the --recursive flag, I only found directories at depth 1.

mocha --recusive $(find test -not \( -path test/utilities -prune \) -not \( -path test/integration -prune \) -type d -depth 1)
Community
  • 1
  • 1
Johnny
  • 136
  • 3
  • 1
    Worked like a charm! NB: if embedding that command into package.json be sure to double escape the escapes. – Thomas Hunter II Jan 08 '15 at 20:58
  • `-d` is now deprecated, should be `-depth` instead: ```mocha --recusive $(find test -not \( -path test/utilities -prune \) -not \( -path test/integration -prune \) -type d -depth 1)``` – Gaston Feb 04 '15 at 16:15