addons/isl/integrationTests/README.mdblame
View source
b69ab311# Integration tests
b69ab312
b69ab313ISL integration tests create a real `sl` repo and run actual `sl` commands, to validate the end-to-end workflow.
b69ab314
b69ab315That said, integration tests differ from "real" use of ISL in a few ways:
b69ab316
b69ab317- Integration tests run in a single process, using a fake MessageBus. This means the client and server are in the same process.
b69ab318- Integration tests are not built using vite, but just run directly by jest. This may have different import ordering properties than production builds.
b69ab319- Integration tests have some mocks, such as tracking (to avoid actually writing tracking data)
b69ab3110- Integration test repos are obviously synthetic and may behave different from "normal" clones.
b69ab3111
b69ab3112Integration tests run one at a time, to avoid overlapping causing issues.
b69ab3113
b69ab3114To run Integration tests:
b69ab3115
b69ab3116```sh
b69ab3117yarn integration
b69ab3118```
b69ab3119
b69ab3120You can use other jest CLI args like normal:
b69ab3121
b69ab3122```sh
b69ab3123yarn integration testName
b69ab3124```
b69ab3125
b69ab3126## Writing integration tests
b69ab3127
b69ab3128See existing tests for examples of how to write an integration test.
b69ab3129Generally:
b69ab3130
b69ab3131- Write tests in the `integrationTests/` directory, with `.test.tsx` names.
b69ab3132- Use react testing library to make assertions about the UI like normal
b69ab3133- Currently expect one test per file, though multiple may be possible with careful repo setup and management
b69ab3134- Call `await initRepo()` at the start of the test. It sets up the real repo and provides various utils
b69ab3135- Call `await act(cleanup)` at the end of the test
b69ab3136- **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