File: test/tests_crashes.js

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly SDK for Node.js   test/tests_crashes.js   Download  
File: test/tests_crashes.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Countly SDK for Node.js
Report events to be tracked with by Count.ly API
Author: By
Last change: Refactor Tests
test refactor
Date: 29 days ago
Size: 1,596 bytes
 

Contents

Class file image Download
/* eslint-disable no-console */ /* global runthis */ var Countly = require("../lib/countly"); var hp = require("./helpers/helper_functions"); // init function function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", url: "https://try.count.ly", interval: 10000, max_events: -1, }); } describe("Crash tests", () => { before(async() => { await hp.clearStorage(); }); it("Validate handled error logic", (done) => { // initialize SDK initMain(); // error logic Countly.track_errors(); try { runthis(); } catch (ex) { Countly.log_error(ex); } // read event queue setTimeout(() => { var req = hp.readRequestQueue()[0]; hp.crashRequestValidator(req, true); done(); }, hp.sWait); }); }); // This needs two steps, first creating an error and second checking the logs without erasing, otherwise error would halt the test describe("Unhandled Error logic", () => { before(async() => { await hp.clearStorage(); }); it("Create unhandled rejection", (done) => { // initialize SDK initMain(); // send emitter Countly.track_errors(); process.emit('unhandledRejection'); done(); }); it("Validate unhandled rejection recording", (done) => { setTimeout(() => { var req = hp.readRequestQueue()[0]; hp.crashRequestValidator(req, false); done(); }, hp.mWait); }); });