When I add the test by using jest to my project developed by svelte I encountered error in testing. My test component is
<script lang="ts">
import { push } from "svelte-spa-router";
let order_id: string = "";
let confirming: boolean = false;
let text: string = "Confirming...";
</script>
<div class="h-screen background">
<div class="z-10 py-3 text-center bg-white">
<img class="m-auto" src="pictures/logo.svg" alt="logo" />
</div>
<div class="flex mt-48">
<p class="m-auto text-5xl font-bold">{text}</p>
</div>
</div>
<style>
.background {
background: #efefef;
}
</style>
But when I delete the line
import {push} from "svelte-spa-router";
The error disappears. My test file is
import { render } from "@testing-library/svelte";
import Confirm from "../../pages/Confirm.svelte";
test("should render", () => {
const results = render(Confirm);
expect(() => results.getByText("Confirming...")).not.toThrow();
});
I hope someone help me.
Aucun commentaire:
Enregistrer un commentaire