Skip to content

Commit 79813b2

Browse files
committed
fix: old docs
1 parent 9216d14 commit 79813b2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ This will copy `mock-sw.js` to your public directory.
143143
Just 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+
146148
it("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!");

0 commit comments

Comments
 (0)