i try to play with jest to learn how to test my react application.
I have create a button that will only embed some element to keep the same style constantly.
Here is the code of my button :
export function searchBtn(triggerSearch) {
return (
<div className="d-flex justify-content-center my-3">
<input
type="submit"
className="btn btn-primary w-25"
value="Search"
onClick={(e) => {
e.preventDefault();
triggerSearch();
}}
></input>
</div>
);
}
Here is my test :
const { searchBtn } = require("./SearchBtn");
test("going to try the btn", () => {
function triggerSearch() {}
expect(searchBtn(triggerSearch)).toEqual(
<div className="d-flex justify-content-center my-3">
<input
type="submit"
className="btn btn-primary w-25"
value="Search"
onClick={(e) => {
e.preventDefault();
triggerSearch();
}}
></input>
</div>
);
});
I don't know why i always get this error :
Received: serializes to the same string
Thanks you in advance
Aucun commentaire:
Enregistrer un commentaire