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

Problem with OmitWhen executing code when condition is true #1081

Closed
hoangtran-97 opened this issue Sep 27, 2023 · 2 comments
Closed

Problem with OmitWhen executing code when condition is true #1081

hoangtran-97 opened this issue Sep 27, 2023 · 2 comments

Comments

@hoangtran-97
Copy link

Linking MR that adds OmitWhen for reference and it does not have the example about my use case.

In my example below, when the condition is true, is randomFunction supposed to be invoked? My understanding was that when the condition is met, everything in omitWhen will be omitted.

omitWhen(condition, () => {
      randomFunction()
      test("testSomething", ()=>{})
})
@ealush
Copy link
Owner

ealush commented Sep 27, 2023

Hey @hoangtran-97, thank you for this callout. Yes, this is the expected behavior. I should add it to the documentation.

omitWhen does indeed run everything in its scope. The one thing that doesn't run is the test callback. The reason for it is that Vest keeps track of the tests within it and registers them.

If there's a portion of non vest code that you'd like to omit, you can safely wrap it in a condition (note - do not put Vest api functions in a condition, as it would interfere with this internal registration)

@hoangtran-97
Copy link
Author

Hi @ealush, thank you for the reply 🙏. Hope this can be added to the documentation soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants