routify icon indicating copy to clipboard operation
routify copied to clipboard

add failing E2E test

Open mrjgreen opened this issue 8 months ago • 6 comments

test with

cd test/e2e
npm test

mrjgreen avatar Oct 03 '23 07:10 mrjgreen

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

netlify[bot] avatar Oct 03 '23 07:10 netlify[bot]

Thank you so much for this.

jakobrosenberg avatar Oct 03 '23 07:10 jakobrosenberg

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.

mrjgreen avatar Oct 03 '23 07:10 mrjgreen

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?

jakobrosenberg avatar Oct 03 '23 12:10 jakobrosenberg

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

I'm not on discord.

mrjgreen avatar Oct 03 '23 13:10 mrjgreen

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.

jakobrosenberg avatar Oct 03 '23 16:10 jakobrosenberg