Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module mocking breaks top level requires in other test suites #89

Open
Derpius opened this issue Jul 16, 2023 · 0 comments
Open

Module mocking breaks top level requires in other test suites #89

Derpius opened this issue Jul 16, 2023 · 0 comments
Assignees
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

Comments

@Derpius
Copy link
Member

Derpius commented Jul 16, 2023

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.

@Derpius Derpius added 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 labels Jul 16, 2023
@github-project-automation github-project-automation bot moved this to Backlog in Lest Jul 16, 2023
@Derpius Derpius self-assigned this Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Status: Backlog
Development

No branches or pull requests

1 participant