@lcrespilho/playwright-fixtures
v2.0.0
Published
Playwright fixtures for dataLayer, collects_ga3 and collects_ga4
Downloads
6
Readme
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