- You want to have your e2e tests less coupled to your code and acting more like a real user
- You don't have a QA team and you want to have some e2e tests to make sure that main user flow will not break, so you need to write it as fast and easily as you can.
npm i puppeteer-tools
puppeteer-tools is like a plugin to puppeteer, so you need to install it too.
npm i puppeteer
import puppeteer from 'puppeteer';
import createPuppeteerTools from 'puppeteer-tools';
const browser = await puppeteer.launch();
const page = await browser.newPage();
const puppeteerTools = createPuppeteerTools(page);
await page.goto('http://myapp.com/login');
await puppeteerTools.form.fill([
{
data: 'mylogin',
label: 'Login',
type: 'text',
},
{
data: 'mypass',
label: 'Password',
type: 'text',
},
]);
await Promise.all([
page.waitForNavigation(),
page.click('button[type=submit]'),
]);
- More input types (check, radio, textarea, ...)
- Custom input types
- Possibility to execute some action between inputs fill in form.fill
Not organized yet, so for now reach me on twitter @lebreRafael or just open issues and PRs