1.0.6 • Published 2 years ago
cypress-plugin-pubsub v1.0.6
NOT READY! An overhaul is coming!
Cypress Plugin PubSubJS
This plugin use the PubSubJS library for pub/sub operations and adds it to window
object.
Installation
Add the plugin into you repository based on below command:
npm i cypress-plugin-pubsub
yarn add cypress-plugin-pubsub
Usage
Inside your project
import cypress-plugin-pubsub
in your main
file. This helps you to access window.PubSub
import 'cypress-plugin-pubsub';
If you are using Typescript
you should add the following line of code to top of your main
file too.
/// <reference types="cypress-plugin-pubsub" />
Now you are able to use pub/sub functionalities as following:
window.PubSub.publish('notification-update', 1);
window.PubSub.subscribe(
'notification-update',
(message: string, data: number) => {
console.log('notification received.');
console.log(data);
notificationCount.value += data;
},
);
Inside Cypress
import cypress-plugin-pubsub
in your support/commands.js
Cypress file.
import 'cypress-plugin-pubsub';
Now you have new Cypress commands to pub/sub. like:
cy.publish('notification-update', 12);
You are able to access to all the PubSubJS
functionalities via window.PubSub
and cy
objects.