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