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

Executing a test using render fails when vitest re-executes #18

Closed
mathieuprog opened this issue Oct 8, 2022 · 4 comments
Closed

Executing a test using render fails when vitest re-executes #18

mathieuprog opened this issue Oct 8, 2022 · 4 comments

Comments

@mathieuprog
Copy link

mathieuprog commented Oct 8, 2022

When running npm test with vitest, you don't get the command line back, you may type the Enter key and the test re-executes, or it will re-execute automatically on file changes.

My tests succeed on the first run, but when I press Enter to re-execute, the test fails.

To reproduce:

  1. Clone https://github.com/mathieuprog/solid-compose
  2. Update solidjs dep as we mentioned here: Second argument to insertBefore may be undefined solid#1265 in /web/dist/dev.js line 476, as we use happy-dom
  3. Run npm test (tests succeed)
  4. Press Enter (test failed)
@jnlmmln
Copy link

jnlmmln commented Oct 13, 2022

When I use vitest v0.22.1 it works fine. After updating to v0.23.0 it stops working.

I think it is related to this PR: vitest-dev/vitest#1754

Because setting isolate: true in vite.config.ts fixes this issue.

Here is a demo: https://stackblitz.com/edit/solidjs-templates-6usthc?file=vite.config.ts

@mathieuprog
Copy link
Author

Thank you with that option isolate: true it works.

The remaining question is, is it normal that no HTMLElement are to be found on second run when isolate option is set to false?
Can the library force to ignore it?
Can we document it?
Is it normal that developers spend literally hours or days on obscure configuration tweaking, instead of coding their actual app functionalities?

@jnlmmln
Copy link

jnlmmln commented Oct 14, 2022

Regarding the issue that the DOM is empty. When I rerun the tests I get this warning from solidjs:

Unrecognized value. Skipped inserting HTMLButtonElement { '$$click': [Function (anonymous)] }
Unrecognized value. Skipped inserting HTMLButtonElement { '$$click': [Function (anonymous)] }
Unrecognized value. Skipped inserting HTMLElement {}

Which comes from solid-js/web/dist/dev.js:446, and is because of value instanceof Node is false for all reruns. So the "nodes" don't get added to the DOM for reruns.

@atk
Copy link
Collaborator

atk commented Nov 6, 2022

This is an error in vitest. The newest version of vitest, if configured correctly, should work. Our testing documentation will be updated soon.

@atk atk closed this as completed Nov 6, 2022
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

3 participants