[X] I have searched all issues to ensure it has not already been reported.
Summary
Pester v5 represents a breaking change. .test.ps1 scripts which run correctly for v5 do not run correctly for v4 and vice-versa.
A user may need to run tests written against both Pester versions, and have both versions of pester installed. The InvokePesterStub will currently only load the latest one. It does seem to have an option to require version 5, but there is no similar option to require version 4, and there is no UI mechanism for triggering those constraints anyway.
Proposed Design
Minimum: Provide a setting to choose the default pester version, and change InvokePesterStub to use the default
Alternative 1: Provide separate "Run all v5 tests" and "Run all v4 tests" commands
Ideal Alternative: Enable InvokePesterStub to detect the correct version based on the content of the loaded file, rather than using the default.
In all cases, the stub must unload the previously loaded module if it is different than the required module.
Prerequisites
Summary
Pester v5 represents a breaking change. .test.ps1 scripts which run correctly for v5 do not run correctly for v4 and vice-versa. A user may need to run tests written against both Pester versions, and have both versions of pester installed. The InvokePesterStub will currently only load the latest one. It does seem to have an option to require version 5, but there is no similar option to require version 4, and there is no UI mechanism for triggering those constraints anyway.
Proposed Design
In all cases, the stub must unload the previously loaded module if it is different than the required module.