nordcloud / serverless-mocha-plugin

Plugin for Serverless Framework which adds support for test-driven development using Mocha
MIT License
159 stars 50 forks source link

How to run all tests that are in different directories #140

Open amimas opened 3 years ago

amimas commented 3 years ago

Hi,

I'm working with a project that has several functions organized in different directories. The tests are also in corresponding directories. Below is an example of what the directory structure looks like.

.
└── handlers
    ├── function-one
    │   ├── fixtures
    │   └── test
    ├── function-two
    │   ├── fixtures
    │   └── test
    ├── function-three
    │   ├── fixtures
    │   └── test

Right now I can run tests for each of those individual functions by running sls invoke test --function function-one --path=handlers/function-one/test.

Is there an option so that I can run tests for all functions? I tried to use a glob pattern for the path parameter (i.e. sls invoke test --path=handlers/**/test), but that doesn't work.

Ofcourse I can create a separate script to parse through each directories and then run the tests for each function as a separate invokation. I'm wondering if there's a native way of handling this without requiring a separate script.

dattran1999 commented 3 years ago

What is the error message? I found something on stackoverflow that might be useful https://stackoverflow.com/questions/10753288/how-to-specify-test-directory-for-mocha