In Joystick, tests are only recognized if they are located in the /tests
folder at the root of your app. Additionally, all test files must be named following the pattern <test_file_name>.test.js
. Any file that does not include the .test.js
suffix will be ignored by the test runner.
Recommended Folder Structure
While you’re not required to do so, it’s highly recommended that the contents of your /tests
folder mirror the structure of your project’s root directory. For example:
- Tests for a utility function in
/lib
should live in/tests/lib
. - Tests for page components in
/ui/pages
should live in/tests/ui/pages
.
Example Project Structure
Project Structure
/api
-- /books
---- getters.js
/lib
-- slugify_title.js
/ui
-- /pages
---- /books
------ index.js
Mirrored Tests Folder
/tests Folder
/tests
-- /api
---- /books
------ getters.test.js
-- /lib
---- slugify_title.test.js
-- /ui
---- /pages
------ /books
-------- index.test.js
Writing Test Files
Each test file should only contain tests relevant to the mirrored path in your app. Treat each test file as a “suite” of related tests. Joystick’s testing system does not provide an explicit suite()
function for organizing tests; instead, the file itself acts as the container for related test cases.
This structure helps ensure your tests remain organized and easy to maintain as your project grows.