Skip to content

Instantly share code, notes, and snippets.

@psygo
Last active December 23, 2020 23:32
Show Gist options
  • Save psygo/aa349b23f56991d4ad9c808c2e2587b6 to your computer and use it in GitHub Desktop.
Save psygo/aa349b23f56991d4ad9c808c2e2587b6 to your computer and use it in GitHub Desktop.
JS Tests with Puppeteer

JS Tests with Puppeteer

1. Resources

2. Testing

2.1. Integration Tests with Puppeteer

puppeteer is basically a headless version of Chrome.

  1. Install puppeteer:
    npm i --save-dev puppeteer
  2. Import it:
    const puppeteer = require('puppeteer');
  3. Simple test:
    test('should click around', async () => {
        const browser = await puppeteer.launch({
            headless: false,
            slowMo: 80,
            args: ['--window-size=1920,1080']
        });
        const page = await browser.newPage();
        await page.goto('<url>');
        await page.click('input#name');
        await page.type('input#name', 'Anna');
        await page.click('input#age');
        await page.type('input#age', '28');
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment