roxiness / routify

Automated Svelte routes
https://routify.dev
1.87k stars 87 forks source link

add failing E2E test #531

Open mrjgreen opened 1 year ago

mrjgreen commented 1 year ago

test with

cd test/e2e
npm test
netlify[bot] commented 1 year ago

Deploy Preview for routify-v3-example canceled.

Name Link
Latest commit 49556ce931eaad30ad92788187d1e9fceb45e670
Latest deploy log https://app.netlify.com/sites/routify-v3-example/deploys/651bc4a8d12d6f00085d66b5
jakobrosenberg commented 1 year ago

Thank you so much for this.

mrjgreen commented 1 year ago

No problem - I've no idea if this will work in CI, but it's a starting point for me to try and figure out why the module replacement doesn't seem to be working for me.

I'd be keen to help get these tests into a useful shape though so if you think this could be something we eventually want to merge I'd be happy to make any required changes.

jakobrosenberg commented 1 year ago

Thanks again for the PR. I'm thinking this should probably be an integration test rather than E2E. I don't know if this is something you want to try. If not, I'll be happy to do it.

Also, are you on Discord by any chance?

mrjgreen commented 1 year ago

I'd be happy enough to try - would that belong in test/integration/routify-runtime/routify.test.js ?

I'm not on discord.

jakobrosenberg commented 1 year ago

I think the best place would be test/integration/composition. Similar to test/integration/meta.

You would have to do something like

    const { default: routes } = await import('./temp/routes.default.js')
    const instance = new RoutifyRuntime({ routes })
    const router = instance.routers[0]
    await router.url.push('/some/route')
    const route = router.activeRoute.get()

    // run tests on route.fragments. Each fragment contains a node with a component to be rendered. Eg. a `reset` would have fewer fragments than a `prepend`
    assert.equal(route.fragments.map(fragment => fragment.node.name), [/*names of nodes to be rendered*/])

But really. You should only do this for your enjoyment since I expect you might hit some obstacles due to the lack of documentation for R3s internal code.