Module mocking breaks top level requires in other test suites #89
Labels
bug
Something isn't working
jira ticket
This issue was created from a Jira ticket during the migration to GitHub issues
scope - mocking
Function and module mocking
Context
When mocking a module with lest outside of a test function, the mock is applied immediately when the file is initially loaded to register tests.
This causes calls to require, loadfile, and dofile at the top level / describe level of other test suites to be mocked, but the mock should be scoped to the file where the mock was added.
Solution
To solve this we need to store mocks separately for each file in the runtime, then use them only while scanning the file for tests, and while running the tests in that file.
The text was updated successfully, but these errors were encountered: