@lcrespilho/playwright-fixtures
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

PubSub

Kind: global class

new PubSub()

Utilizes the Observer Pattern, where the Page is the producer and the Node Playwright Test is the consumer. Every time the Page produces a message (window.dataLayer.push, or GA-Universal/GA4 network request), the consumer's subscribers callbacks are called.

pubSub.subscribe(subscriber)

Subscribe for messages. Used by the consumer.

Kind: instance method of PubSub

Param Type Description
subscriber function callback function to be executed once the message arrives

pubSub.unsubscribe(subscriber)

Unsubscribe from messages. Used by the consumer.

Kind: instance method of PubSub

Param Type Description
subscriber function reference to a callback function previously subscribed

pubSub.publish(message)

Publish messages. Used by the producer.

Kind: instance method of PubSub

Param Type Description
message Message message published.

pubSub.waitForMessage([config]) ⇒ Promise.<Message>

Returns a promise that will be resolved when a message matching WaitForMessageOptions is found, or rejected if WaitForMessageOptions.timeout is reached. Used by the consumer.

Kind: instance method of PubSub
Returns: Promise.<Message> - message published.

Param Type
[config] WaitForMessageOptions

How to publish to npm registry

https://www.youtube.com/watch?v=Nh9xW2-ZOEU

Readme

Keywords

none

Package Sidebar

Install

npm i @lcrespilho/playwright-fixtures

Weekly Downloads

2

Version

2.0.0

License

ISC

Unpacked Size

15.9 kB

Total Files

6

Last publish

Collaborators

  • lcrespilho