I have the following setup for running the 'it' tests:
X is environment variable
if( X == "all" || X == "some value" )
read directory and run test using it() with callbacks
if( X == "all" || X == "some other value")
read directory and run some it() tests with callback
The problem I am facing is when i give "some value" or "some other value", all the it() tests run just fine. But when environment variable is "all", while running the first it() tests, the directory contents of the second if statement is appearing. I am using fs.readdirSync(dir) to read the contents and I know mochatest runs them asynchronously and hence, the content of second directory is appearing in the first tests. Is it possible to block the execution of second if statement till all the it() tests in the first if gets completed successfully? or any alternative to make it run synchronously.