File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,7 +143,11 @@ This will copy `mock-sw.js` to your public directory.
143143Just call ` await twd.initRequestMocking() ` at the start of your test , then use ` twd.mockRequest ` to define your mocks . Example :
144144
145145` ` ` ts
146+ import { describe, it, twd, userEvent } from "twd-js";
147+
146148it("fetches a message", async () => {
149+ twd.visit("/");
150+ const user = userEvent.setup();
147151 await twd.mockRequest("message", {
148152 method: "GET",
149153 url: "https://api.example.com/message",
@@ -152,7 +156,7 @@ it("fetches a message", async () => {
152156 },
153157 });
154158 const btn = await twd.get("button[data-twd='message-button']");
155- btn .click();
159+ await user .click(btn.el );
156160 await twd.waitForRequest("message");
157161 const messageText = await twd.get("p[data-twd='message-text']");
158162 messageText.should("have.text", "Mocked message!");
You can’t perform that action at this time.
0 commit comments