New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nightmare-custom-event

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nightmare-custom-event

Add custom events to NightmareJS

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

nightmare-custom-event

Allows for adding custom events to Nightmare.

Usage

Require the library and pass the Nightmare library as a reference to attach the plugin actions:

var Nightmare = require('nightmare');
require('nightmare-custom-event')(Nightmare);

... and then you're able to use bind and unbind.

.bind(name [, handler])

Adds a custom event that can be captured with .on() triggerable in .evaluate() or .inject() with ipc.send([name], ...). The optional handler will consume the named event.

.unbind(name [, handler])

Removes a custom event added with .bind(). If handler is specified, the handler is removed. If no handler is specified or the handler was the last handler for the emitter, the custom event is removed and will no longer be emittable until it is bound again.

Example

var onResults;
yield nightmare
  .goto(fixture('events'))
  .bind('sample-event', handler)
  .on('sample-event', function(msg) {
    onResults = msg.sample;
   })
   .evaluate(function() {
     ipc.send('sample-event', 'sample', 3, {
       sample: 'sample'
      });
   });

// ... do something intermediate ...

yield nightmare.
    unbind('sample-event');

Keywords

FAQs

Package last updated on 22 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc