Home

Puppeteer Recorder

Use this to convert a db.json events file into someting usable with puppeteer.

Install

Currently this is a lib file that needs to be installed using kratos.

Usage

Use the Emitter common JS class to handle this. Ensure you sub to the event action.

// Example of emission with type inferred handlePrimaryClick = (e) => { Emitter.emit('action', { event: 'ComponentALLandingOne.handlePrimaryClick', e: e.target }); const { router } = this.props; router.push('/testTwo'); }; // Example of emission with type manually specified handleLink = (e) => { e.preventDefault(); Emitter.emit('action', { event: 'ComponentALLandingOne.handleLink', type: 'link', e: e.target }); const { router } = this.props; router.push('/testTwo'); };

Generating the tests

The recorder relies on JSON DB and using the events endpoint.

# usage node path/to/recorder

The console log output for this guy can then be transferred to a test file to use with Puppeteer.

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/puppeteer/recorder

Sections


Related