How to run a single test?

Hi there, how can i run a single test in redwood? the problem is, that i have 2 test files named: projects.test.ts and asdfprojects.test.ts. When i run yarn rw test api projects it runs the tests from both asdfprojects and projects.
is there any way to only run projects.test.ts?

Cheers and thanks!

Hey @pcace - it seems like your syntax is correct for filtering and running a single test. Looking here: Testing | RedwoodJS Docs

Filtering what tests to run​

You can run only the web- or api-side test suites by including the side as another argument to the command:

yarn rw test web
yarn rw test api

Let’s say you have a test file called CommentForm.test.js. In order to only watch and run tests in this file you can run

yarn rw test CommentForm

If you need to be more specific, you can combine side filters, with other filters

yarn rw test api Comment

which will only run test specs matching “Comment” in the API side

Maybe it the filter is not explicit and is more of a wildcard and picking up multiple files with the word project in it? Try running your command with the exact casing of your test file.

If this syntax is not working for you, and if noone else replies with a better answer, it may be worth submitting as a GitHub issue - possible bug.

This is exactly how it works :slight_smile:

Try yarn rw test api projects.test.ts If you’re still getting too many tests running, include parts of the path as well, so maybe yarn rw test api projects/projects.test.ts

1 Like