Q1.Where should each kind of test run in a CI/CD pipeline?
Short answer: fastest and most reliable checks first, slow ones later, and each stage blocks the next.
pull request : lint -> unit -> API/contract -> UI smoke (minutes, blocks merge)
main branch : full API + UI regression in parallel (blocks deploy to staging)
after deploy : smoke against the deployed environment (blocks promotion)
nightly : long suites, cross-browser, performance baseline
The goal is fast feedback on the change a developer just made, not running everything everywhere.
