| 1 | # Integration tests |
| 2 | |
| 3 | ISL integration tests create a real `sl` repo and run actual `sl` commands, to validate the end-to-end workflow. |
| 4 | |
| 5 | That said, integration tests differ from "real" use of ISL in a few ways: |
| 6 | |
| 7 | - Integration tests run in a single process, using a fake MessageBus. This means the client and server are in the same process. |
| 8 | - Integration tests are not built using vite, but just run directly by jest. This may have different import ordering properties than production builds. |
| 9 | - Integration tests have some mocks, such as tracking (to avoid actually writing tracking data) |
| 10 | - Integration test repos are obviously synthetic and may behave different from "normal" clones. |
| 11 | |
| 12 | Integration tests run one at a time, to avoid overlapping causing issues. |
| 13 | |
| 14 | To run Integration tests: |
| 15 | |
| 16 | ```sh |
| 17 | yarn integration |
| 18 | ``` |
| 19 | |
| 20 | You can use other jest CLI args like normal: |
| 21 | |
| 22 | ```sh |
| 23 | yarn integration testName |
| 24 | ``` |
| 25 | |
| 26 | ## Writing integration tests |
| 27 | |
| 28 | See existing tests for examples of how to write an integration test. |
| 29 | Generally: |
| 30 | |
| 31 | - Write tests in the `integrationTests/` directory, with `.test.tsx` names. |
| 32 | - Use react testing library to make assertions about the UI like normal |
| 33 | - Currently expect one test per file, though multiple may be possible with careful repo setup and management |
| 34 | - Call `await initRepo()` at the start of the test. It sets up the real repo and provides various utils |
| 35 | - Call `await act(cleanup)` at the end of the test |
| 36 | - **Important:** Do not import files at the top level that use ISL dependencies. Instead, use the `await import()` syntax. This is important since `initRepo()` sets up mocks that MUST happen before ANY other `isl/src` imports |
| 37 | |