File: cypress/integration/web_worker_queues.js

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly Web SDK   cypress/integration/web_worker_queues.js   Download  
File: cypress/integration/web_worker_queues.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Countly Web SDK
Track site accesses and errors the Countly API
Author: By
Last change:
Date: 5 months ago
Size: 1,394 bytes


Class file image Download
describe("Web Worker Local Queue Tests", () => { it("Verify queues for all features", () => { // create a worker const myWorker = new Worker("../../examples/mpa/worker_for_test.js"); // send an event to worker myWorker.postMessage({ data: { key: "key" }, type: "event" }); myWorker.postMessage({ data: "begin_session", type: "session" }); myWorker.postMessage({ data: "end_session", type: "session" }); myWorker.postMessage({ data: "home_page", type: "view" }); // ask for local queues myWorker.postMessage({ data: "queues", type: "get" }); let requestQueue; let eventQueue; myWorker.onmessage = function(e) { requestQueue =; // Array of requests eventQueue =; // Array of events myWorker.terminate(); // terminate worker // verify event queue expect(eventQueue.length).to.equal(2); cy.check_event(eventQueue[0], { key: "key" }, undefined, false); cy.check_view_event(eventQueue[1], "home_page", undefined, false); // verify request queue expect(requestQueue.length).to.equal(2); cy.check_session(requestQueue[0], undefined, false, false, true); cy.check_session(requestQueue[1], 0, false, false, false); }; }); });