# Convenient Test Executor for Node.js
6 May 2018
I was really surprised not finding a convenient test runner/executor in **npm** that can run test scripts in directory/directories recursively from the code. Also it would be nice to log how many tests are failed and passed, log stack traces of failed scripts, and log execution time. Moreover, I wanted to run scripts asynchronously. So, I decided that it's a great opportunity to create a such tool. I've called it **test-executor**, and it's iteresting that this name was available in **npm**. In this article I'll explain how this library works and how to use it. [This library](https://github.com/Guseyn/node-test-executor) is based on [Async Tree Pattern](/pdf/Async_Tree_Pattern.pdf). And that's how you can use it: ```js const { ExecutedTests } = require('test-executor') new ExecutedTests( './test/test.js', './test/dir1', './test/dir2' ).call() ``` Or, if you want to run everything in **test** directory, you can just type ```js new ExecutedTests('./test').call() ``` You can specify files or/and directories in arguments. In case of directories, it runs them recursively. The main feature of this library is that it runs tests asynchronously. It forces you to write tests independetly, thereby they are more stable and maintainable. Here is an example of output (case when one of the tests fail): ![output](https://github.com/Guseyn/node-test-executor/raw/master/screen.png)
References
P.S. I know that there are test runners like Mocha, Jest, Ava, and so on. But, in my opinion, this library is much more pleasant to use. * [Test Executor on GitHub](https://github.com/Guseyn/node-test-executor) [Reddit Comments](https://www.reddit.com/r/node/comments/b2ajit/the_first_test_executor_for_nodejs/) / [HN Comments](https://news.ycombinator.com/item?id=19416882)