Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyraspopov committed Mar 26, 2024
1 parent caf9e91 commit ef4a388
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
5 changes: 4 additions & 1 deletion docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export default defineConfig({
themeConfig: {
search: { provider: "local" },

nav: [{ text: "Guide", link: "/introduction" }],
nav: [
{ text: "Guide", link: "/introduction" },
{ text: "API", link: "/ref/rollwright" },
],

sidebar: [
{
Expand Down
11 changes: 7 additions & 4 deletions examples/react/dialog.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ interface Props extends DialogProps {
}

let test = base.extend<{ Dialog: JSHandle<(props: Props) => JSX.Element> }>({
plugins: async ({ plugins }, use) => {
// override here
await use(plugins);
},
Dialog: async ({ execute }, use) => {
let Component = await execute(async () => {
let { Root, Trigger, Overlay, Content, Title, Close, Portal } = await import(
Expand All @@ -37,6 +33,13 @@ let test = base.extend<{ Dialog: JSHandle<(props: Props) => JSX.Element> }>({
},
});

test.use({
plugins: async ({ plugins }, use) => {
// override here
await use(plugins);
},
});

test("basic", async ({ mount, Dialog, page }) => {
let component = await mount(
(Dialog) => <Dialog openLabel="Open" closeLabel="Close" title="Title" />,
Expand Down
29 changes: 29 additions & 0 deletions examples/vanilla/libmock.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect } from "@playwright/test";
import { test as base } from "rollwright";

let test = base.extend({
sinon: async ({ execute }, use) => {
let sinon = await execute(() => import("sinon"));
await use((fn) => execute(fn, sinon));
},
});

test("example", async ({ page, sinon, execute }) => {
let cb = await sinon((lib) => lib.stub());
let spy = await sinon((lib) => lib.spy(console));

await execute((cb) => {
let button = document.createElement("button");
button.addEventListener("click", () => {
console.log("clicked");
cb();
});
console.log("created");
document.body.append(button);
}, cb);

await page.click("button");

expect(await cb.evaluate((m) => m.callCount)).toEqual(1);
expect(await spy.evaluate((spy) => spy.log.args)).toEqual([["created"], ["clicked"]]);
});

0 comments on commit ef4a388

Please sign in to comment.