-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I'm writing unit tests to validate correct pages are appearing on navigation change. I am using Svelte Testing Library.
I can not provide the actual code due to privacy reasons but here is the gist of it.
App.svelte
<script lang="ts">
import { Router, routes } from "svelte-hash-router"
import PageOne from "./PageOne.svelte"
routes.set({
"page-one": PageOne
})
</script>App.test.ts
it('should render header', async () => {
const { getByTestId } = render(App)
window.location.href = "/#/page-one"
await waitFor(() => getByTestId("header"))
expect(getByTestId("title")).toBeInTheDocument()
})
it("should render main", async () => {
const { getByTestId } = render(App)
window.location.href = "/#/page-one"
await waitFor(() => getByTestId("main"))
})When I run the tests the first one passes, but the second test outputs the following error: TypeError: routes.set is not a function
I had a look through the code and noticed this:
I'm wondering why set needs to be removed.
Metadata
Metadata
Assignees
Labels
No labels