Best JavaScript code snippet using stryker-parent
50-file_spec.js
Source:50-file_spec.js
1/**2 * Copyright 2015 IBM Corp.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 **/16var should = require("should");17var path = require('path');18var fs = require('fs-extra');19var sinon = require("sinon");20var fileNode = require("../../../../nodes/core/storage/50-file.js");21var helper = require("../../helper.js");22describe('file Nodes', function() {23 describe('file out Node', function() {24 var resourcesDir = path.join(__dirname,"..","..","..","resources");25 var fileToTest = path.join(resourcesDir,"50-file-test-file.txt");26 var wait = 150;27 beforeEach(function(done) {28 //fs.writeFileSync(fileToTest, "File message line 1\File message line 2\n");29 helper.startServer(done);30 });31 afterEach(function(done) {32 helper.unload().then(function() {33 //fs.unlinkSync(fileToTest);34 helper.stopServer(done);35 });36 });37 it('should be loaded', function(done) {38 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":true}];39 helper.load(fileNode, flow, function() {40 var fileNode1 = helper.getNode("fileNode1");41 fileNode1.should.have.property('name', 'fileNode');42 done();43 });44 });45 it('should write to a file', function(done) {46 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":true}];47 helper.load(fileNode, flow, function() {48 var n1 = helper.getNode("fileNode1");49 n1.emit("input", {payload:"test"});50 setTimeout(function() {51 var f = fs.readFileSync(fileToTest);52 f.should.have.length(4);53 fs.unlinkSync(fileToTest);54 done();55 },wait);56 });57 });58 it('should append to a file and add newline', function(done) {59 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":false}];60 helper.load(fileNode, flow, function() {61 var n1 = helper.getNode("fileNode1");62 n1.emit("input", {payload:"test2"}); // string63 setTimeout(function() {64 n1.emit("input", {payload:true}); // boolean65 },50);66 setTimeout(function() {67 var f = fs.readFileSync(fileToTest).toString();68 f.should.have.length(11);69 f.should.equal("test2\ntrue\n");70 done();71 },wait);72 });73 });74 it('should use msg.filename if filename not set in node', function(done) {75 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "appendNewline":true, "overwriteFile":true}];76 helper.load(fileNode, flow, function() {77 var n1 = helper.getNode("fileNode1");78 n1.emit("input", {payload:"fine", filename:fileToTest});79 setTimeout(function() {80 var f = fs.readFileSync(fileToTest).toString();81 f.should.have.length(5);82 f.should.equal("fine\n");83 done();84 },wait);85 });86 });87 it('should be able to delete the file', function(done) {88 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":"delete"}];89 helper.load(fileNode, flow, function() {90 var n1 = helper.getNode("fileNode1");91 n1.emit("input", {payload:"fine"});92 setTimeout(function() {93 try {94 var f = fs.readFileSync(fileToTest).toString();95 f.should.not.equal("fine");96 //done();97 }98 catch(e) {99 e.code.should.equal("ENOENT");100 done();101 }102 },wait);103 });104 });105 it('should warn if filename not set', function(done) {106 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "appendNewline":true, "overwriteFile":false}];107 helper.load(fileNode, flow, function() {108 var n1 = helper.getNode("fileNode1");109 n1.emit("input", {payload:"nofile"});110 setTimeout(function() {111 try {112 var f = fs.readFileSync(fileToTest).toString();113 f.should.not.equal("fine");114 //done();115 }116 catch(e) {117 var logEvents = helper.log().args.filter(function(evt) {118 return evt[0].type == "file";119 });120 //console.log(logEvents);121 logEvents.should.have.length(1);122 logEvents[0][0].should.have.a.property('msg');123 logEvents[0][0].msg.toString().should.equal("file.errors.nofilename");124 done();125 }126 },wait);127 });128 });129 it('ignore a missing payload', function(done) {130 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":false}];131 helper.load(fileNode, flow, function() {132 var n1 = helper.getNode("fileNode1");133 setTimeout(function() {134 try {135 var f = fs.readFileSync(fileToTest).toString();136 f.should.not.equal("fine");137 //done();138 }139 catch(e) {140 var logEvents = helper.log().args.filter(function(evt) {141 return evt[0].type == "file";142 });143 //console.log(logEvents);144 logEvents.should.have.length(0);145 done();146 }147 },wait);148 n1.emit("input", {topic:"test"});149 });150 });151 it('should fail to write to a ro file', function(done) {152 // Stub file write so we can make writes fail153 var spy = sinon.stub(fs, 'writeFile', function(arg1,arg2,arg3,arg4) {154 arg4(new Error("Stub error message"));155 });156 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":true}];157 helper.load(fileNode, flow, function() {158 var n1 = helper.getNode("fileNode1");159 setTimeout(function() {160 try {161 var logEvents = helper.log().args.filter(function(evt) {162 return evt[0].type == "file";163 });164 //console.log(logEvents);165 logEvents.should.have.length(1);166 logEvents[0][0].should.have.a.property('msg');167 logEvents[0][0].msg.toString().should.startWith("file.errors.writefail");168 done();169 }170 catch(e) { done(e); }171 finally { fs.writeFile.restore(); }172 },wait);173 n1.receive({payload:"test"});174 });175 });176 it('should fail to append to a ro file', function(done) {177 // Stub file write so we can make writes fail178 var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });179 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":false}];180 helper.load(fileNode, flow, function() {181 var n1 = helper.getNode("fileNode1");182 setTimeout(function() {183 try {184 var logEvents = helper.log().args.filter(function(evt) {185 return evt[0].type == "file";186 });187 //console.log(logEvents);188 logEvents.should.have.length(1);189 logEvents[0][0].should.have.a.property('msg');190 logEvents[0][0].msg.toString().should.startWith("file.errors.appendfail");191 done();192 }193 catch(e) { done(e); }194 finally { fs.appendFile.restore(); }195 },wait);196 n1.receive({payload:"test2"});197 });198 });199 it('should cope with failing to delete a file', function(done) {200 // Stub file write so we can make writes fail201 var spy = sinon.stub(fs, 'unlink', function(arg,arg2){ arg2(new Error("Stub error message")); });202 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":"delete"}];203 helper.load(fileNode, flow, function() {204 var n1 = helper.getNode("fileNode1");205 setTimeout(function() {206 try {207 var logEvents = helper.log().args.filter(function(evt) {208 return evt[0].type == "file";209 });210 //console.log(logEvents);211 logEvents.should.have.length(1);212 logEvents[0][0].should.have.a.property('msg');213 logEvents[0][0].msg.toString().should.startWith("file.errors.deletefail");214 done();215 }216 catch(e) { done(e); }217 finally { fs.unlink.restore(); }218 },wait);219 n1.receive({payload:"test2"});220 });221 });222 it('should fail to create a new directory if not asked to do so (append)', function(done) {223 // Stub file write so we can make writes fail224 var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt");225 //var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });226 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":false}];227 helper.load(fileNode, flow, function() {228 var n1 = helper.getNode("fileNode1");229 setTimeout(function() {230 try {231 var logEvents = helper.log().args.filter(function(evt) {232 return evt[0].type == "file";233 });234 //console.log(logEvents);235 logEvents.should.have.length(1);236 logEvents[0][0].should.have.a.property('msg');237 logEvents[0][0].msg.toString().should.startWith("file.errors.appendfail");238 done();239 }240 catch(e) { done(e); }241 //finally { fs.appendFile.restore(); }242 },wait);243 n1.receive({payload:"test2"});244 });245 });246 it('should try to create a new directory if asked to do so (append)', function(done) {247 // Stub file write so we can make writes fail248 var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt");249 var spy = sinon.stub(fs, "ensureFile", function(arg1,arg2,arg3,arg4) { arg2(null); });250 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":false, "createDir":true}];251 helper.load(fileNode, flow, function() {252 var n1 = helper.getNode("fileNode1");253 setTimeout(function() {254 try {255 var logEvents = helper.log().args.filter(function(evt) {256 return evt[0].type == "file";257 });258 //console.log(logEvents);259 logEvents.should.have.length(1);260 logEvents[0][0].should.have.a.property('msg');261 logEvents[0][0].msg.toString().should.startWith("file.errors.appendfail");262 done();263 }264 catch(e) { done(e); }265 finally { fs.ensureFile.restore(); }266 },wait);267 n1.receive({payload:"test2"});268 });269 });270 it('should fail to create a new directory if not asked to do so (overwrite)', function(done) {271 // Stub file write so we can make writes fail272 var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt");273 //var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });274 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":false, "overwriteFile":true}];275 helper.load(fileNode, flow, function() {276 var n1 = helper.getNode("fileNode1");277 setTimeout(function() {278 try {279 var logEvents = helper.log().args.filter(function(evt) {280 return evt[0].type == "file";281 });282 //console.log(logEvents);283 logEvents.should.have.length(1);284 logEvents[0][0].should.have.a.property('msg');285 logEvents[0][0].msg.toString().should.startWith("file.errors.writefail");286 done();287 }288 catch(e) { done(e); }289 //finally { fs.appendFile.restore(); }290 },wait);291 n1.receive({payload:"test2"});292 });293 });294 it('should try to create a new directory if asked to do so (overwrite)', function(done) {295 // Stub file write so we can make writes fail296 var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt");297 var spy = sinon.stub(fs, "ensureFile", function(arg1,arg2,arg3,arg4){ arg2(null); });298 var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":true, "createDir":true}];299 helper.load(fileNode, flow, function() {300 var n1 = helper.getNode("fileNode1");301 setTimeout(function() {302 try {303 var logEvents = helper.log().args.filter(function(evt) {304 return evt[0].type == "file";305 });306 //console.log(logEvents);307 logEvents.should.have.length(1);308 logEvents[0][0].should.have.a.property('msg');309 logEvents[0][0].msg.toString().should.startWith("file.errors.writefail");310 done();311 }312 catch(e) { done(e); }313 finally { fs.ensureFile.restore(); }314 },wait);315 n1.receive({payload:"test2"});316 });317 });318 });319 describe('file in Node', function() {320 var resourcesDir = path.join(__dirname,"..","..","..","resources");321 var fileToTest = path.join(resourcesDir,"50-file-test-file.txt");322 var wait = 150;323 beforeEach(function(done) {324 fs.writeFileSync(fileToTest, "File message line 1\File message line 2\n");325 helper.startServer(done);326 });327 afterEach(function(done) {328 helper.unload().then(function() {329 fs.unlinkSync(fileToTest);330 helper.stopServer(done);331 });332 });333 it('should be loaded', function(done) {334 var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":fileToTest, "format":"utf8"}];335 helper.load(fileNode, flow, function() {336 var n1 = helper.getNode("fileInNode1");337 n1.should.have.property('name', 'fileInNode');338 done();339 });340 });341 it('should read in a file and output a buffer', function(done) {342 var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":fileToTest, "format":"", wires:[["n2"]]},343 {id:"n2", type:"helper"}];344 helper.load(fileNode, flow, function() {345 var n1 = helper.getNode("fileInNode1");346 var n2 = helper.getNode("n2");347 n2.on("input", function(msg) {348 msg.should.have.property('payload');349 msg.payload.should.have.length(39).and.be.a.Buffer;350 msg.payload.toString().should.equal("File message line 1\File message line 2\n");351 done();352 });353 n1.receive({payload:""});354 });355 });356// Commented out to make build pass on node v.0.8 - reinstate when we drop 0.8 support...357 //it('should read in a file and output a utf8 string', function(done) {358 //var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":fileToTest, "format":"utf8", wires:[["n2"]]},359 //{id:"n2", type:"helper"}];360 //helper.load(fileNode, flow, function() {361 //var n1 = helper.getNode("fileInNode1");362 //var n2 = helper.getNode("n2");363 //n2.on("input", function(msg) {364 //msg.should.have.property('payload');365 //msg.payload.should.have.length(39).and.be.a.string;366 //msg.payload.should.equal("File message line 1\File message line 2\n");367 //done();368 //});369 //n1.receive({payload:""});370 //});371 //});372// Commented out as we no longer need to warn of the very old deprecated behaviour373 //it('should warn if msg.props try to overide', function(done) {374 //var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":fileToTest, "format":"", wires:[["n2"]]},375 //{id:"n2", type:"helper"}];376 //helper.load(fileNode, flow, function() {377 //var n1 = helper.getNode("fileInNode1");378 //var n2 = helper.getNode("n2");379 //n2.on("input", function(msg) {380 //msg.should.have.property('payload');381 //msg.payload.should.have.length(39).and.be.a.Buffer;382 //msg.payload.toString().should.equal("File message line 1\File message line 2\n");383 //var logEvents = helper.log().args.filter(function(evt) {384 //return evt[0].type == "file in";385 //});386 //logEvents.should.have.length(1);387 //logEvents[0][0].should.have.a.property('msg');388 //logEvents[0][0].msg.toString().should.startWith("file.errors.nooverride");389 //done();390 //});391 //n1.receive({payload:"",filename:"foo.txt"});392 //});393 //});394 it('should warn if no filename set', function(done) {395 var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "format":""}];396 helper.load(fileNode, flow, function() {397 var n1 = helper.getNode("fileInNode1");398 setTimeout(function() {399 var logEvents = helper.log().args.filter(function(evt) {400 return evt[0].type == "file in";401 });402 logEvents.should.have.length(1);403 logEvents[0][0].should.have.a.property('msg');404 logEvents[0][0].msg.toString().should.equal("file.errors.nofilename");405 done();406 },wait);407 n1.receive({});408 });409 });410 it('should handle a file read error', function(done) {411 var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":"badfile", "format":""}];412 helper.load(fileNode, flow, function() {413 var n1 = helper.getNode("fileInNode1");414 setTimeout(function() {415 var logEvents = helper.log().args.filter(function(evt) {416 return evt[0].type == "file in";417 });418 logEvents.should.have.length(1);419 logEvents[0][0].should.have.a.property('msg');420 //logEvents[0][0].msg.toString().should.equal("Error: ENOENT, open 'badfile'");421 logEvents[0][0].msg.toString().should.startWith("Error: ENOENT");422 done();423 },wait);424 n1.receive({payload:""});425 });426 });427 });...
reloadConfiguration-test.js
Source:reloadConfiguration-test.js
1"use strict";2var vows = require('vows')3, assert = require('assert')4, sandbox = require('sandboxed-module');5function setupConsoleTest() {6 var fakeConsole = {}7 , logEvents = []8 , log4js;9 10 ['trace','debug','log','info','warn','error'].forEach(function(fn) {11 fakeConsole[fn] = function() {12 throw new Error("this should not be called.");13 };14 });15 log4js = sandbox.require(16 '../lib/log4js', 17 {18 globals: {19 console: fakeConsole20 }21 }22 );23 log4js.clearAppenders();24 log4js.addAppender(function(evt) {25 logEvents.push(evt);26 });27 return { log4js: log4js, logEvents: logEvents, fakeConsole: fakeConsole };28}29vows.describe('reload configuration').addBatch({30 'with config file changing' : {31 topic: function() {32 var pathsChecked = [],33 logEvents = [],34 logger,35 modulePath = 'path/to/log4js.json',36 fakeFS = {37 lastMtime: Date.now(),38 config: { 39 appenders: [ 40 { type: 'console', layout: { type: 'messagePassThrough' } } 41 ],42 levels: { 'a-test' : 'INFO' } 43 },44 readFileSync: function (file, encoding) {45 assert.equal(file, modulePath);46 assert.equal(encoding, 'utf8');47 return JSON.stringify(fakeFS.config);48 },49 statSync: function (path) {50 pathsChecked.push(path);51 if (path === modulePath) {52 fakeFS.lastMtime += 1;53 return { mtime: new Date(fakeFS.lastMtime) };54 } else {55 throw new Error("no such file");56 }57 }58 },59 fakeConsole = {60 'name': 'console',61 'appender': function () {62 return function(evt) { logEvents.push(evt); };63 },64 'configure': function (config) {65 return fakeConsole.appender();66 }67 },68 setIntervalCallback,69 fakeSetInterval = function(cb, timeout) {70 setIntervalCallback = cb;71 },72 log4js = sandbox.require(73 '../lib/log4js',74 {75 requires: {76 'fs': fakeFS,77 './appenders/console': fakeConsole78 },79 globals: {80 'console': fakeConsole,81 'setInterval' : fakeSetInterval,82 }83 }84 );85 86 log4js.configure('path/to/log4js.json', { reloadSecs: 30 });87 logger = log4js.getLogger('a-test');88 logger.info("info1");89 logger.debug("debug2 - should be ignored");90 fakeFS.config.levels['a-test'] = "DEBUG";91 setIntervalCallback();92 logger.info("info3");93 logger.debug("debug4");94 95 return logEvents;96 },97 'should configure log4js from first log4js.json found': function(logEvents) {98 assert.equal(logEvents[0].data[0], 'info1');99 assert.equal(logEvents[1].data[0], 'info3');100 assert.equal(logEvents[2].data[0], 'debug4');101 assert.equal(logEvents.length, 3);102 }103 },104 105 'with config file staying the same' : {106 topic: function() {107 var pathsChecked = [],108 fileRead = 0,109 logEvents = [],110 logger,111 modulePath = require('path').normalize(__dirname + '/../lib/log4js.json'),112 mtime = new Date(),113 fakeFS = {114 config: { 115 appenders: [ 116 { type: 'console', layout: { type: 'messagePassThrough' } } 117 ],118 levels: { 'a-test' : 'INFO' } 119 },120 readFileSync: function (file, encoding) {121 fileRead += 1;122 assert.isString(file);123 assert.equal(file, modulePath);124 assert.equal(encoding, 'utf8');125 return JSON.stringify(fakeFS.config);126 },127 statSync: function (path) {128 pathsChecked.push(path);129 if (path === modulePath) {130 return { mtime: mtime };131 } else {132 throw new Error("no such file");133 }134 }135 },136 fakeConsole = {137 'name': 'console',138 'appender': function () {139 return function(evt) { logEvents.push(evt); };140 },141 'configure': function (config) {142 return fakeConsole.appender();143 }144 },145 setIntervalCallback,146 fakeSetInterval = function(cb, timeout) {147 setIntervalCallback = cb;148 },149 log4js = sandbox.require(150 '../lib/log4js',151 {152 requires: {153 'fs': fakeFS,154 './appenders/console': fakeConsole155 },156 globals: {157 'console': fakeConsole,158 'setInterval' : fakeSetInterval,159 }160 }161 );162 163 log4js.configure(modulePath, { reloadSecs: 3 });164 logger = log4js.getLogger('a-test');165 logger.info("info1");166 logger.debug("debug2 - should be ignored");167 setIntervalCallback();168 logger.info("info3");169 logger.debug("debug4");170 171 return [ pathsChecked, logEvents, modulePath, fileRead ];172 },173 'should only read the configuration file once': function(args) {174 var fileRead = args[3];175 assert.equal(fileRead, 1);176 },177 'should configure log4js from first log4js.json found': function(args) {178 var logEvents = args[1];179 assert.equal(logEvents.length, 2);180 assert.equal(logEvents[0].data[0], 'info1');181 assert.equal(logEvents[1].data[0], 'info3');182 }183 },184 'when config file is removed': {185 topic: function() {186 var pathsChecked = [],187 fileRead = 0,188 logEvents = [],189 logger,190 modulePath = require('path').normalize(__dirname + '/../lib/log4js.json'),191 mtime = new Date(),192 fakeFS = {193 config: { 194 appenders: [ 195 { type: 'console', layout: { type: 'messagePassThrough' } } 196 ],197 levels: { 'a-test' : 'INFO' } 198 },199 readFileSync: function (file, encoding) {200 fileRead += 1;201 assert.isString(file);202 assert.equal(file, modulePath);203 assert.equal(encoding, 'utf8');204 return JSON.stringify(fakeFS.config);205 },206 statSync: function (path) {207 this.statSync = function() {208 throw new Error("no such file");209 };210 return { mtime: new Date() };211 }212 },213 fakeConsole = {214 'name': 'console',215 'appender': function () {216 return function(evt) { logEvents.push(evt); };217 },218 'configure': function (config) {219 return fakeConsole.appender();220 }221 },222 setIntervalCallback,223 fakeSetInterval = function(cb, timeout) {224 setIntervalCallback = cb;225 },226 log4js = sandbox.require(227 '../lib/log4js',228 {229 requires: {230 'fs': fakeFS,231 './appenders/console': fakeConsole232 },233 globals: {234 'console': fakeConsole,235 'setInterval' : fakeSetInterval,236 }237 }238 );239 240 log4js.configure(modulePath, { reloadSecs: 3 });241 logger = log4js.getLogger('a-test');242 logger.info("info1");243 logger.debug("debug2 - should be ignored");244 setIntervalCallback();245 logger.info("info3");246 logger.debug("debug4");247 248 return [ pathsChecked, logEvents, modulePath, fileRead ];249 },250 'should only read the configuration file once': function(args) {251 var fileRead = args[3];252 assert.equal(fileRead, 1);253 },254 'should not clear configuration when config file not found': function(args) {255 var logEvents = args[1];256 assert.equal(logEvents.length, 3);257 assert.equal(logEvents[0].data[0], 'info1');258 assert.equal(logEvents[1].level.toString(), 'WARN');259 assert.include(logEvents[1].data[0], 'Failed to load configuration file');260 assert.equal(logEvents[2].data[0], 'info3');261 }262 },263 'when passed an object': {264 topic: function() {265 var test = setupConsoleTest();266 test.log4js.configure({}, { reloadSecs: 30 });267 return test.logEvents;268 },269 'should log a warning': function(events) {270 assert.equal(events[0].level.toString(), 'WARN');271 assert.equal(272 events[0].data[0], 273 'Ignoring configuration reload parameter for "object" configuration.'274 );275 }276 },277 'when called twice with reload options': {278 topic: function() {279 var modulePath = require('path').normalize(__dirname + '/../lib/log4js.json'),280 fakeFS = {281 readFileSync: function (file, encoding) {282 return JSON.stringify({});283 },284 statSync: function (path) {285 return { mtime: new Date() };286 }287 },288 fakeConsole = {289 'name': 'console',290 'appender': function () {291 return function(evt) { };292 },293 'configure': function (config) {294 return fakeConsole.appender();295 }296 },297 setIntervalCallback,298 intervalCleared = false,299 clearedId,300 fakeSetInterval = function(cb, timeout) {301 setIntervalCallback = cb;302 return 1234;303 },304 log4js = sandbox.require(305 '../lib/log4js',306 {307 requires: {308 'fs': fakeFS,309 './appenders/console': fakeConsole310 },311 globals: {312 'console': fakeConsole,313 'setInterval' : fakeSetInterval,314 'clearInterval': function(interval) {315 intervalCleared = true;316 clearedId = interval;317 }318 }319 }320 );321 322 log4js.configure(modulePath, { reloadSecs: 3 });323 log4js.configure(modulePath, { reloadSecs: 15 });324 325 return { cleared: intervalCleared, id: clearedId };326 },327 'should clear the previous interval': function(result) {328 assert.isTrue(result.cleared);329 assert.equal(result.id, 1234);330 }331 }...
Using AI Code Generation
1var stryker = require('stryker-parent');2stryker.logEvents();3var stryker = require('stryker-parent');4stryker.logEvents();5var stryker = require('stryker-parent');6stryker.logEvents();7var stryker = require('stryker-parent');8stryker.logEvents();9var stryker = require('stryker-parent');10stryker.logEvents();11var stryker = require('stryker-parent');12stryker.logEvents();13var stryker = require('stryker-parent');14stryker.logEvents();15var stryker = require('stryker-parent');16stryker.logEvents();17var stryker = require('stryker-parent');18stryker.logEvents();19var stryker = require('stryker-parent');20stryker.logEvents();21var stryker = require('stryker-parent');22stryker.logEvents();23var stryker = require('stryker-parent');24stryker.logEvents();25var stryker = require('stryker-parent');26stryker.logEvents();27var stryker = require('stryker-parent');28stryker.logEvents();29var stryker = require('stryker
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const logEvents = strykerParent.logEvents;3const log4js = require('log4js');4log4js.configure({5 appenders: {6 console: {7 }8 },9 categories: {10 default: {11 }12 }13});14const logger = log4js.getLogger('test');15logEvents.on('log', (logEvent) => {16 logger.debug(logEvent);17});18logEvents.emit('log', 'this is a test');19module.exports = function(config) {20 config.set({21 commandRunner: {22 }23 });24}
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.logEvents('test', 'test');3var strykerParent = require('stryker-parent');4strykerParent.logEvents('test', 'test');5var strykerParent = require('stryker-parent');6strykerParent.logEvents('test', 'test');7var strykerParent = require('stryker-parent');8strykerParent.logEvents('test', 'test');9var strykerParent = require('stryker-parent');10strykerParent.logEvents('test', 'test');11var strykerParent = require('stryker-parent');12strykerParent.logEvents('test', 'test');13var strykerParent = require('stryker-parent');14strykerParent.logEvents('test', 'test');15var strykerParent = require('stryker-parent');16strykerParent.logEvents('test', 'test');17var strykerParent = require('stryker-parent');18strykerParent.logEvents('test', 'test');19var strykerParent = require('stryker-parent');20strykerParent.logEvents('test', 'test');21var strykerParent = require('stryker-parent');22strykerParent.logEvents('test', 'test');23var strykerParent = require('stryker-parent');24strykerParent.logEvents('test', 'test');
Using AI Code Generation
1const strykerParent = require('stryker-parent');2strykerParent.logEvents('test', 'test message');3const strykerParent = require('stryker-parent');4strykerParent.logEvents('test', 'test message');5const strykerParent = require('stryker-parent');6strykerParent.logEvents('test', 'test message');7const strykerParent = require('stryker-parent');8strykerParent.logEvents('test', 'test message');9const strykerParent = require('stryker-parent');10strykerParent.logEvents('test', 'test message');11const strykerParent = require('stryker-parent');12strykerParent.logEvents('test', 'test message');13const strykerParent = require('stryker-parent');14strykerParent.logEvents('test', 'test message');15const strykerParent = require('stryker-parent');16strykerParent.logEvents('test', 'test message');17const strykerParent = require('stryker-parent');18strykerParent.logEvents('test', 'test message');19const strykerParent = require('stryker-parent');20strykerParent.logEvents('test', 'test message');21const strykerParent = require('stryker-parent');22strykerParent.logEvents('test', 'test message');23const strykerParent = require('stryker-parent');
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.logEvents('test', 'test');3var strykerParent = require('stryker-parent');4strykerParent.logEvents('test', 'test');5var strykerParent = require('stryker-parent');6strykerParent.logEvents('test', 'test');7var strykerParent = require('stryker-parent');8strykerParent.logEvents('test', 'test');9var strykerParent = require('stryker-parent');10strykerParent.logEvents('test', 'test');11var strykerParent = require('stryker-parent');12strykerParent.logEvents('test', 'test');13var strykerParent = require('stryker-parent');14strykerParent.logEvents('test', 'test');15var strykerParent = require('stryker-parent');16strykerParent.logEvents('test', 'test');17var strykerParent = require('stryker-parent');18strykerParent.logEvents('test', 'test');19var strykerParent = require('stryker-parent');20strykerParent.logEvents('test', 'test');21var strykerParent = require('stryker-parent');22strykerParent.logEvents('test', 'test');23var strykerParent = require('stryker-parent');24strykerParent.logEvents('test', 'test');
Using AI Code Generation
1var logEvents = require('stryker-parent').logEvents;2logEvents.on('test', function (test) {3 console.log(test.name);4});5logEvents.on('testResult', function (testResult) {6 console.log(testResult.name);7});8logEvents.on('allTestResults', function (allTestResults) {9 console.log(allTestResults);10});11logEvents.on('error', function (error) {12 console.log(error);13});14logEvents.on('allMutantsTested', function (allMutantsTested) {15 console.log(allMutantsTested);16});17logEvents.on('progress', function (progress) {18 console.log(progress);19});20logEvents.on('allMutantsTested', function (allMutantsTested) {21 console.log(allMutantsTested);22});23logEvents.on('allMutantsTested', function (allMutantsTested) {24 console.log(allMutantsTested);25});26logEvents.on('mutantTested', function (mutantTested) {27 console.log(mutantTested);28});29logEvents.on('mutantKilled', function (mutantKilled) {30 console.log(mutantKilled);31});32logEvents.on('mutantSurvived', function (mutantSurvived) {33 console.log(mutantSurvived);34});35logEvents.on('mutantTimeout', function (mutantTimeout) {36 console.log(mutantTimeout);37});38logEvents.on('mutantCompileErrors', function (mutantCompileErrors) {39 console.log(mutantCompileErrors);40});41logEvents.on('mutantRunError', function (mutantRunError) {42 console.log(mutantRunError);43});44logEvents.on('mutantIgnored', function (mutantIgnored) {45 console.log(mutantIgnored);46});47logEvents.on('bail', function (bail) {48 console.log(bail);49});50logEvents.on('bailResult', function (bailResult) {51 console.log(bailResult);52});53logEvents.on('scoreCalculated', function (scoreCalculated) {54 console.log(scoreCalculated);55});56logEvents.on('allMutantsTested', function (allMutantsTested) {57 console.log(allMutantsTested);58});59logEvents.on('allMutantsTested', function (allMutantsTested) {60 console.log(allMutantsTested);61});
Using AI Code Generation
1var logEvents = require('stryker-parent').logEvents;2logEvents.on('test', function (test) {3});4var logEvents = require('./src/logEvents');5module.exports = {6};7var EventEmitter = require('events').EventEmitter;8var logEvents = new EventEmitter();9module.exports = logEvents;10var logEvents = require('./logEvents');11logEvents.emit('test', { name: 'test' });12var logEvents = require('stryker-parent').logEvents;13logEvents.on('test', function (test) {14});15var logEvents = require('./src/logEvents');16module.exports = {17};18var EventEmitter = require('events').EventEmitter;19var logEvents = new EventEmitter();20module.exports = logEvents;21var logEvents = require('./logEvents');22logEvents.emit('test', { name: 'test' });23var logEvents = require('stryker-parent').logEvents;24logEvents.on('test', function (test) {25});26var logEvents = require('./src/logEvents');27module.exports = {28};29var EventEmitter = require('events').EventEmitter;30var logEvents = new EventEmitter();31module.exports = logEvents;32var logEvents = require('./logEvents');33logEvents.emit('test', { name: 'test' });34var logEvents = require('stryker-parent').logEvents;35logEvents.on('test', function (test) {36});37var logEvents = require('./src/logEvents');38module.exports = {39};
Using AI Code Generation
1const strykerParent = require("stryker-parent");2const test = () => {3 strykerParent.logEvents("test", "test");4};5test();6const strykerParent = require("stryker-parent");7module.exports.logEvents = strykerParent.logEvents;8const strykerParent = require("stryker-parent");9module.exports.logEvents = strykerParent.logEvents;10const strykerParent = require("stryker-parent");11module.exports.logEvents = strykerParent.logEvents;12const strykerParent = require("stryker-parent");13module.exports.logEvents = strykerParent.logEvents;14const strykerParent = require("stryker-parent");15module.exports.logEvents = strykerParent.logEvents;16const strykerParent = require("stryker-parent");17module.exports.logEvents = strykerParent.logEvents;18const strykerParent = require("stryker-parent");19module.exports.logEvents = strykerParent.logEvents;20const strykerParent = require("stryker-parent");21module.exports.logEvents = strykerParent.logEvents;22const strykerParent = require("stryker-parent");23module.exports.logEvents = strykerParent.logEvents;24const strykerParent = require("stryker-parent");25module.exports.logEvents = strykerParent.logEvents;26const strykerParent = require("stryker-parent");27module.exports.logEvents = strykerParent.logEvents;
Using AI Code Generation
1var stryker = require('stryker-parent');2stryker.logEvents();3stryker.end();4var stryker = require('stryker-parent');5stryker.logEvents();6stryker.end();7at Object. (C:\Jenkins\workspace\project\test.js:4:9)8at Module._compile (module.js:652:30)9at Object.Module._extensions..js (module.js:663:10)10at Module.load (module.js:565:32)11at tryModuleLoad (module.js:505:12)12at Function.Module._load (module.js:497:3)13at Module.require (module.js:596:17)14at require (internal/module.js:11:18)15at Object. (C:\Jenkins\workspace\project\node_modules\stryker\src\api\Stryker.js:4:22)16at Module._compile (module.js:652:30)17at Object.Module._extensions..js (module.js:663:10)18at Module.load (module.js:565:32)19at tryModuleLoad (module.js:505:12)20at Function.Module._load (module.js:497:3)21at Module.require (module.js:596:17)22at require (internal/module.js:11:18)23at Object. (C:\Jenkins\workspace\project\node_modules\stryker\src\index.js:1:18)24at Module._compile (module.js:652:30)25at Object.Module._extensions..js (module.js:663:10)26at Module.load (module
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!