1.0.1 • Published 8 months ago

puppeteer-recording-helpers v1.0.1

Weekly downloads
-
License
Unlicense
Repository
github
Last release
8 months ago

puppeteer-recording-helpers

Test helpers for playback of puppeteer recordings from Chrome Devtool Recorder.

E.g. for use with test frameworks like mocha, jest, ava, ...

install

npm init -y
npm install -D puppeteer puppeteer-recording-helpers

usage

  1. open Chrome browser and open Developer Tools

    • "CTRL + Shift + I" (Windows/ Linux)
    • "CMD + option + I" (Mac)
  2. open Tab "Recorder" and start recording Open Recorder Tab

  3. Execute your click flow... Record Click Flow

  4. Export as puppeteer script Export script

  5. Extract the click steps from the exported script and enhance with provided helpers.

    import { openBrowser } from 'puppeteer-recording-helpers'
    
    ;(async () => {
    
    const { browser, page, timeout } = openBrowser()
    const messages = consoleLog(page)
    
    // >>>snip>>> copy the contents from Chrome Devtools Recording
    {
      const targetPage = page
      await targetPage.setViewport({ width: 800, height: 600 })
    }
    {
      const targetPage = page
      const promises = []
      promises.push(targetPage.waitForNavigation())
      await targetPage.goto('https://todomvc.com/examples/react/#/')
      await Promise.all(promises)
    }
    // ...
    browser.close()
    // <<<snip<<<
    
    })()

    See ./test/todomvc.spec.js for modified recording.

  6. Run your tests

    npm test

helpers

license

The Unlicense

contributing

Any Pull-Request for fixing or enhancing the helpers is welcome.

references