File: cypress/e2e/web_worker_queues.cy.js

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly Web SDK   cypress/e2e/web_worker_queues.cy.js   Download  
File: cypress/e2e/web_worker_queues.cy.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: 8 days ago
Size: 1,414 bytes
 

Contents

Class file image Download
describe("Web Worker Local Queue Tests", () => { it("Verify queues for all features", () => { // create a worker const myWorker = new Worker("../../test_workers/worker_for_test.js", { type: "module" }); // 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 = e.data.requestQ; // Array of requests eventQueue = e.data.eventQ; // 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); }; }); });