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

Test passes, but fails with .then() #1720

Closed
6 tasks done
kevmul opened this issue Jul 25, 2022 · 1 comment
Closed
6 tasks done

Test passes, but fails with .then() #1720

kevmul opened this issue Jul 25, 2022 · 1 comment

Comments

@kevmul
Copy link

kevmul commented Jul 25, 2022

Describe the bug

I have a test where I set the props when creating the wrapper. After testing everything lines up, I change my props with an await wrapper.setProps(). The following assertions pass, but the assertions for computed properties do not pass. As if they are not updating after the await.

I then thought to try removing the await and creating a .then() function to see if that works, and ran into this interesting issue. My test passes, but fails after within the .then() function.

image

I believe this is similar to #1692

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-ef3jdp?file=test/computed.test.js

This should create a quick Vite app with Vue 2.7 and Vitest.

Once created, the test runner should fire, and you will see that 1 test passes, and 1 test fails. They check the exact same stuff, just have to deal with the await vs then

System Info

Mac M1
Vite:    2.9.14
Vitest:  0.18.1
Node:    18.6.0 / 16.16.0 (I tried on both)
Vue:     2.7.7 (cannot upgrade to v3 yet :/ )

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Jul 26, 2022

This is correct behaviour. Code inside then is running after test is done, so we can’t catch it. Return a promise from test, or use await.

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants