Skip to content

Commit 192a99f

Browse files
committed
Add a paragraph on test file naming
1 parent 95586c2 commit 192a99f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/src/modules/4-testing/4-unit/4-unit.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ The testing library used by this repository is [`vitest`](https://vitest.dev).
1313
By default, any Typescript (`.ts`) files located within a `__tests__` folder are considered test files. This means that if `vitest` does not
1414
detect any tests within that file, it will throw an error. This also includes any subdirectories under a `__tests__` folder.
1515

16-
Simply write your tests within a `__tests__` folder:
16+
> [!WARNING] Test File Naming
17+
> Right now any file ending with `.ts` or `.tsx` will be considered a test file. This is inconvenient, especially if you want to create a set of
18+
> common utilities to be used only for tests. Such a file might (_READ: should_) not contain any tests, which will be considered by Vitest to be
19+
> an error.
20+
>
21+
> To remedy this, in the future, only files that end in `.test.ts` or `.test.tsx` will be considered test files. This will allow us to have regular
22+
> Typescript files located within `__tests__` directories. This means you should use that naming convention instead when creating your test files.
23+
>
24+
> The current behaviour is retained for backwards compatibility since many Source modules' tests aren't written within `.test.ts` files. To see
25+
> examples of how to use this new system you can refer to how the tests for the buildtools are written.
26+
27+
Simply write your tests within a file within a `__tests__` folder:
1728

1829
```ts
1930
// curve/src/__tests__/index.ts
@@ -132,7 +143,7 @@ TODO tests still generate an entry in your test reports, but will be considered
132143
To run tests for a given bundle or tab, simply run either of the following commands within the directory:
133144

134145
```sh
135-
yarn buildtools test .
146+
yarn buildtools test --project .
136147
yarn test # If your package.json has this script specified
137148
```
138149

0 commit comments

Comments
 (0)