Open yairkukielka opened 1 month ago
Thanks for the report @yairkukielka
I am not able to reproduce it on my end.
What happens if you run npm init routify@latest
and select starter-basic
with all components included. Then run npm run test
. Make sure the ssr is enabled:
routify({ render: { ssr: { enable: true } } }),
Ok, I tried but the test failed :)
FAIL tests/test.spec.js > can see /
AssertionError: expected '' to contain 'Welcome to Your New Routify 3 Project!'
- Expected
+ Received
- Welcome to Your New Routify 3 Project!
❯ tests/test.spec.js:15:37
13| await router.url.push('/')
14|
15| expect(document.body.innerHTML).toContain('Welcome to Your New Routify 3 Project!')
| ^
16| })
17|
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests 1 failed (1)
Start at 18:38:17
I couldn't make it pass. In any case, what you suggested is a different project. Mine doesn't use ssr, it's an SPA. Could you try my example?
The ssr
wasn't needed. Blunder on my part.
Tried your code. Seems you're missing
<script context="module">
in your App.svelte
.
Without context="module"
the export below doesn't work.
export const router = createRouter({ routes });
Let me know if this works for you. 😊
Hello, thanks for taking a look. Unfortunately that didn't fix it. I replaced <script>
with <script context="module">
but I'm still getting the same problem when I run tests:
close timed out after 10000ms
Tests closed successfully but something prevents Vite server from exiting
You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/config/#reporters
I fixed some timing issues related to testing, could you try the following
mkdir mytest
cd mytest
npm init routify@latest . -- -t starter-basic -i -p npm -v 3 --features test -r
npm run test
Hello, this isn't using my reproduction example, is it? I think it would be useful to fix it there
I can't tell if it fixes your example as I couldn't reproduce the error when I ran it.
If the commands above work for you, we'll have something to go on in terms of fixing the issue.
Describe the bug
When running the tests it looks like the process hangs at the end, just after passing the tests.
Reproduction
When running tests with vitest. The issue gets resolved if I remove the routify plugin from the vite config file, so it looks like routify is the culprit. After the Vitest default 10 seconds timout, the process is killed by Vitest
See reproduction example here https://github.com/yairkukielka/routify-vitest-example
Logs
If I add this
to the vite config as the error suggests, I get