-
Notifications
You must be signed in to change notification settings - Fork 6
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
[jest-plugin-set] Set variables should be created before beforeEach is called #71
Comments
@negativetwelve I wonder what this is about. When you mix in own
|
Hi @bxt, thanks for your comment. If I remember correctly, the issue comes from something like:
It will log:
when it should be:
and if I remember correctly, the test should fail on this and return 2 instead of 10. Let me know if you're seeing the same behavior. (I wrote the code without testing, please excuse if there are small errors) |
Hey @negativetwelve, wow thank you for your fast answer! It also fails for me but slightly different. It outputs
And:
So only the indirect calculation of (node I think one can get rid of all |
oops you're right (I kept editing my responses haha). It's definitely a caching issue because of the order that the I stumbled upon this issue when using I mainly use
something like this ^ |
I ran into this also today. Here's another repro. describe('', () => {
set('a', () => x)
beforeEach(() => {
console.log(a);
})
describe('', () => {
set('x', () => 1)
test('', () => {
expect(a).toEqual(1)
})
})
}) Fails with Pulling variables from inner contexts to use in beforeEach is definitely a useful pattern which can eliminate a lot of duplicate code. Something I always do in rspec. |
Description
Nested
set
calls must ALL come beforebeforeEach
in order to be set properly. Otherwise, it'll use the values from outerset
calls which is incorrectScreenshot
Test Plan
The text was updated successfully, but these errors were encountered: