You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keep code decoupled and functions small and atomic.
6
+
Always keep testability in mind.
7
+
8
+
## Unit Tests
9
+
10
+
If new functionality is developed, unit tests should be written for it.
11
+
We use the testing framework `vitest`.
12
+
Run all tests using `npm run test`.
13
+
14
+
Unit tests should test small blocks of the code, mainly individual functions.
15
+
A few parts of the code (e.g., the worker for validation) can not be executed by the unit tests.
16
+
Hence, every code that has a dependency to these untestable parts needs to specify mocks for these parts.
17
+
To avoid the need for writing many mocks, keep the coupling as small as possible and avoid importing more than needed.
18
+
If, for example, a file imports from the `main.ts` script, it indirectly imports everything which `main.ts` refers to, which is almost all of the project.
19
+
Therefore, when `main.ts` is imported, to write tests for your components you need to mock many components.
20
+
This should be avoided and instead the dependencies which you need should be extracted from the `main.ts` into a smaller, independent, file.
21
+
22
+
## E2E Tests
23
+
24
+
This project also has end-to-end tests which open MetaConfigurator in a browser and then simulate different clicks and keyboard inputs to test the full behavior of the app.
25
+
More details can be found in the [e2e test directory](../meta_configurator/e2e).
0 commit comments