Integration testing in Zsh is about proving that the system behaves as one. Not just a script. Not just a function. All of it — the environment, the commands, the configuration, the edge cases. When you run tests here, you verify the complete chain from input to output.
Zsh integration testing starts with environment control. Use a clean, predictable test shell. Avoid inherited variables that can sabotage results. For isolated testing, spawn Zsh in a subshell with --no-rcs to skip user config. This ensures the same conditions every run.
Next, structure tests into executable scripts. Wrap target commands in functions. Pipe output to comparison tools like diff or leverage testing frameworks such as BATS. Integration tests should mimic real workflows: chaining commands, handling failures, and reading from stdin. Capture exit codes. Test for both expected and forbidden side effects.