Best JavaScript code snippet using istanbul
start.js
Source:start.js
...13connection.query("use " + conf.mysql.dbname);14var result = {},15 i = 0;16console.log('æ»è®¡æ£æ¥:' + monitor_list.length + '个ï¼é¢è®¡èæ¶' + monitor_list.length * conf.phantomjs.wait + 'ç§ã');17function runPhantom() {18 var pdps = monitor_list[i++];19 if (pdps) {20 console.log('Monitor:' + pdps);21 exec([conf.phantomjs.path, conf.phantomjs.file, conf.pageurl + '?' + pdps, conf.phantomjs.wait].join(' '), function (error, stdout, stderr) {22 var reqs = JSON.parse(stdout),23 req,24 info,25 httpResult = '',26 httpCode = 0;27 for (var url in reqs) {28 req = {};29 info = 'æå';30 if (!reqs[url].end) {31 info = '失败ï¼è¯·æ±è¶
æ¶';32 } else {33 httpCode = reqs[url].end.status,34 httpResult = reqs[url].end.text || '';35 if (httpCode > 399) {36 info = '失败ï¼ç¶æç é误, ' + httpCode;37 }38 }39 var sql = "INSERT INTO `" + conf.mysql.tablename + "` (`pdps`, `url`, `http_code`, `description`, `http_result`) VALUES('" + pdps + "', '" + url + "', '" + httpCode + "', '" + info + "', '" + httpResult + "')";40 //console.log(sql);41 connection.query(sql, function (err, rows) {42 //console.log(err, rows);43 });44 }45 runPhantom();46 });47 } else {48 connection.end();49 }50}...
headless.js
Source:headless.js
...27}28if (!process.env.TRAVIS) {29 builder.buildW3C(false, function () {30 console.log("Script built");31 runPhantom();32 });33}34else {35 runPhantom();...
phantoProc.js
Source:phantoProc.js
1var util = require( "util" );2var spawn = require( "child_process" ).spawn;3var phantomExecutable = "phantomjs";4var log = function(msg) {5 util.log( "PhatomJS runner: " + msg );6};7var runPhantom = function( callback, klujsDir, port ) {8 var proc = spawn( phantomExecutable, [ klujsDir + "/phantom-runner.js", port] );9 proc.on( 'exit', function( code, signal) {10 log( "PhantomJs ended: " + code + " " + signal );11 callback( code );12 } );13 proc.stdout.on('data', function (data) {14 log( 'stdout: ' + data);15 });16 proc.stderr.on('data', function (data) {17 log( 'stderr: ' + data);18 } );19};...
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!!