marmelab / gremlins.js

Monkey testing library for web apps and Node.js

Home Page:https://marmelab.com/blog/2020/06/02/gremlins-2.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Within Playwright

ilrein opened this issue · comments

commented

I see the docs has an example of how to use gremlins within cypress. Is there a way to do the same, but using Playwright instead?

I have the same question, does this work with playwright? My code is like this:

await page.evaluate(() => { gremlins.createHorde().unleash()}).catch(e => void 0);

And I get window is not defined error. Any help?

Here is something that worked for me

import { test } from "@playwright/test";

test("run gremlins.js", async ({ page }) => {
  await page.addInitScript({
    path: "./node_modules/gremlins.js/dist/gremlins.min.js",
  });
  await page.goto("https://playwright.dev");
  await page.evaluate(() => gremlins.createHorde().unleash());
});

Hi there! I've made a pull request to add an example for Playwright