Best JavaScript code snippet using mocha
ccapi.js
Source:ccapi.js
1/*2 CCAPI.js 3 Author: SKW4 Version: 1.05 Modified: 09/30/20106 Copyright: ExploriaSPS, LLC.7 8 This javascript file holds the definition for all ESP system communication and utility functions.9*/101112/*13 Method that handles a call from ESP with the passed content14 communication xml request string and returns any appropriate15 content communication xml response.16*/17var HandleESPCCAPICall = function(requestXml)18{19 //alert("HandleESPCCAPICall requestXml=" + requestXml);20 // Parse parameters21 var callData = CCAPI.ParseCallParameters( requestXml );2223 // Handle the call24 switch (callData.functionName)25 {26 case CCAPI.SYS_pollCall:27 // System is polling content for any waiting calls28 var espCall = CCAPI.CallToESPQueue.shift();29 if ( espCall )30 {31 //alert("pollCall" + espCall.XmlRequest);32 // There is a call to ESP waiting to be processed33 return espCall.XmlRequest;34 }35 break;36 case CCAPI.SYS_returnCall:3738 //alert("callData=" + callData);39 40 // System is returning a result to a waiting call41 var callback = callData.arguments[0].ToValue();42 var result = callData.arguments[1].ToValue();43 44 // Split out the callback data into the callID and the method to call45 var arr = callback.split(":", 2);46 var callID = arr[0];47 callback = arr[1]; 48 49 if ( callback )50 {51 // Build the proper string to call the callback method52 // passing the callID and the result53 var cb = callback + "(" + callID + ", ";54 if ( typeof result == 'string' )55 cb = cb + JSONEnquote( result );56 else57 cb = cb + result;58 cb = cb + ")";59 // Call the callback method passing the callID and the result60 eval( cb ); 61 }62 break;63 case CCAPI.EVT_slideLoad:64 if ( typeof EVT_slideLoad == 'function' )65 {66 var mode = callData.arguments[0].ToValue();67 var data = callData.arguments[1].ToValue();68 EVT_slideLoad( mode, data );69 }70 break;71 case CCAPI.EVT_slideStart:72 if ( typeof EVT_slideStart == 'function' )73 {74 EVT_slideStart();75 }76 break;77 case CCAPI.EVT_slideEnd:78 // Default to OK to end now with no delay79 var delay = -1;80 if ( typeof EVT_slideEnd == 'function' )81 {82 delay = EVT_slideEnd();83 }8485 // Create a return CCAPI argument86 var argReturn = new CCAPIArgument( delay );8788 // Convert the return argument to an xml string89 var responseXml = argReturn.ToStringForCallCCFunction();9091 return responseXml;92 break;93 }94};9596/*97 Content Communication API class that handles communication between98 host ESP application and the html/javascript content.99*/100function CCAPI()101{102 /* Content Communication API Events sent from ESP to the content */103 CCAPI.EVT_querySAS = "EVT_querySAS";104 CCAPI.EVT_queryPrintDescription = "EVT_queryPrintDescription";105 CCAPI.EVT_print = "EVT_print";106 CCAPI.EVT_slideLoad = "EVT_slideLoad";107 CCAPI.EVT_slideUpdate = "EVT_slideUpdate";108 CCAPI.EVT_slideStart = "EVT_slideStart";109 CCAPI.EVT_slideEnd = "EVT_slideEnd";110 111 /* Content Communication API ESP System Events sent from ESP to the content */112 CCAPI.SYS_pollCall = "SYS_pollCall";113 CCAPI.SYS_returnCall = "SYS_returnCall";114115 /* Content Communication API Messages sent from the content to ESP */116 CCAPI.NAV_restartPresentation = "NAV_restartPresentation";117 CCAPI.NAV_endPresentation = "NAV_endPresentation";118 CCAPI.NAV_resetPresentation = "NAV_resetPresentation";119 CCAPI.NAV_getSlideProperty = "NAV_getSlideProperty";120 CCAPI.NAV_setSlideProperty = "NAV_setSlideProperty";121 CCAPI.NAV_resetSlideOrder = "NAV_resetSlideOrder";122 CCAPI.NAV_goToSlide = "NAV_goToSlide";123 CCAPI.NAV_goToSlideTest = "NAV_goToSlideTest";124 CCAPI.NAV_goToHiddenSlide = "NAV_goToHiddenSlide";125 CCAPI.NAV_goToHiddenSlideTest = "NAV_goToHiddenSlideTest";126 CCAPI.NAV_goNext = "NAV_goNext";127 CCAPI.NAV_goNextTest = "NAV_goNextTest";128 CCAPI.NAV_goBack = "NAV_goBack";129 CCAPI.NAV_goBackTest = "NAV_goBackTest";130 CCAPI.NAV_goToGroup = "NAV_goToGroup";131 CCAPI.NAV_goToGroupTest = "NAV_goToGroupTest";132 CCAPI.NAV_pushHistory = "NAV_pushHistory";133 CCAPI.NAV_popHistory = "NAV_popHistory";134 CCAPI.NAV_nextHistory = "NAV_nextHistory";135 CCAPI.NAV_backHistory = "NAV_backHistory";136 CCAPI.NAV_clearHistory = "NAV_clearHistory";137 CCAPI.NAV_currentHistory = "NAV_currentHistory";138 CCAPI.NAV_arriveMethod = "NAV_arriveMethod";139 CCAPI.NAV_enableToolbarHotArea = "NAV_enableToolbarHotArea";140 CCAPI.NAV_showToolbar = "NAV_showToolbar";141 CCAPI.DB_get = "DB_get";142 CCAPI.DB_set = "DB_set";143 CCAPI.TRK_get = "TRK_get";144 CCAPI.TRK_set = "TRK_set";145 CCAPI.INFO_get = "INFO_get";146 147 // The modes within which a slide can be loaded148 CCAPI.PREVIEW = 1;149 CCAPI.DETAIL = 2;150 CCAPI.NOASSOC = 3;151 152 // The environment types within which a slide can be loaded153 CCAPI.LOCAL = 1;154 CCAPI.WEB = 2;155 156 // The user types for which a slide can be loaded157 CCAPI.DOCTOR = 1;158 CCAPI.REP = 2;159 CCAPI.THIRDPARTY = 3;160 161 // The detail types within which a slide can be loaded162 CCAPI.EDETAIL = 1;163 CCAPI.REMOTEDETAIL = 2;164 CCAPI.INPERSON = 3;165 166 // The slide properties167 CCAPI.TYPE = 1;168 CCAPI.BRANDED = 2;169 CCAPI.BACKGROUNDCOLOR = 3;170 CCAPI.TEXTCOLOR = 4;171 CCAPI.TEXT = 5;172 CCAPI.ENABLED = 6;173 CCAPI.GROUPINDEX = 7;174 CCAPI.GROUPRESET = 8;175 CCAPI.PRINTABLE = 9;176 177 // The scope qualifiers178 CCAPI.SCOPETHIS = 1;179 CCAPI.SCOPEALL = 2;180 181 // The info properties182 //CCAPI.DOCTOR = 1; // THIS IS ALREADY DEFINED UNDER USER TYPES183 //CCAPI.REP = 2; // THIS IS ALREADY DEFINED UNDER USER TYPES184 CCAPI.NUMSLIDES = 3;185 CCAPI.CURRENTSLIDEINDEX = 4;186 CCAPI.TOOLBARHOTAREA = 5;187 CCAPI.TOOLBARRECT = 6;188 CCAPI.RIGHTHANDED = 7;189 CCAPI.HIGHLIGHTTIME = 8;190 CCAPI.LOCALBOOKMARKS = 9;191 CCAPI.POLICIES = 10;192 CCAPI.ZOOMRANGE = 11;193 CCAPI.DEFAULTCURSOR = 12;194 195 // The cursors196 CCAPI.HANDCURSOR = 1;197 CCAPI.ZOOMCURSOR = 2;198199 /* Enumeration of Content Communication API Argument Types */200 CCAPI.ArgumentType = {Undefined:0, String:1, Number:2, Array:3, BooleanTrue:4, BooleanFalse:5, Object:6};201202 /* Counter that holds the next ESP Call ID - it just counts up from 1 */203 CCAPI.NextESPCallID = 1;204 205 /* Queue of waiting calls to host ESP application */206 CCAPI.CallToESPQueue = new Array();207208}209210/*211 Static method that takes a content communication xml request string and212 returns a call data object.213 requestXml: Xml string.214 215 returns: CallData object { functionName:"", arguments:{CCAPIArgument, ..} }. 216*/217CCAPI.ParseCallParameters = function(requestXml)218{219 var callData = new Object();220221 // Load the XML222 var xmlDoc;223 if (window.DOMParser)224 {225 parser=new DOMParser();226 xmlDoc=parser.parseFromString(requestXml,"text/xml");227 }228 else // Internet Explorer229 {230 xmlDoc=new ActiveXObject("Microsoft.XMLDOM");231 xmlDoc.async="false";232 xmlDoc.loadXML(requestXml);233 }234235 // Get the function name236 var invokeNode = xmlDoc;237 238 if (invokeNode.nodeType == 9) // Document node239 {240 // Get the first child241 invokeNode = invokeNode.firstChild;242 }243 callData.functionName = invokeNode.attributes.getNamedItem("name").value;244 245 // Get the arguments246 //var argsNode = invokeNode.selectSingleNode("arguments");247 var argsNode = invokeNode.firstChild;248249 if ( argsNode )250 {251 var args = new Array();252253 for ( var i=0; i<argsNode.childNodes.length; i++ )254 {255 args[i] = new CCAPIArgument( argsNode.childNodes[i] );256 }257258 callData.arguments = args;259 }260261 return callData;262}263264/*265 Static method that takes a content communication xml return string and266 returns a CCAPIArgument.267 requestXml: Xml string.268 269 returns: CCAPIArgument.270*/271CCAPI.ParseCallReturnValue = function(returnedXml)272{273 // Load the XML274 if (window.DOMParser)275 {276 parser=new DOMParser();277 xmlDoc=parser.parseFromString(returnedXml,"text/xml");278 xmlDoc.setProperty("SelectionLanguage","XPath");279 }280 else // Internet Explorer281 {282 xmlDoc=new ActiveXObject("Microsoft.XMLDOM");283 xmlDoc.async="false";284 xmlDoc.loadXML(returnedXml);285 }286287 // Get the argument288 var arg = new CCAPIArgument( xmlDoc );289290 return arg;291}292293/*294 Static method that calls an ESP function with the passed arguments295 and returns a unique ESPCallID.296 297 functionName: String name of the function called.298 callback: String that will be eval(callback) passing the ESPCallID and return value.299 args: Any additional arguments should come here.300 301 returns: ESPCallID which is a unique identifier for the call.302*/303CCAPI.CallESPFunction = function(functionName, callback, args)304{305 // Object to hold the waiting call to be made to the host ESP application306 var espCall = new Object();307308 // Generate a new call ID for this call309 CCAPI.NextESPCallID = CCAPI.NextESPCallID + 1;310 var callID = CCAPI.NextESPCallID;311312 // Make up the xml for calling an ESP content communication function313 var xml = "<invoke name=\"" + functionName + "\""; 314 xml = xml + " callback=\"" + callID + ":" + callback + "\"";315 xml = xml + " returntype=\"xml\">";316 317 // Build the xml for the arguments to pass through ESP content communication function318 if ( args )319 {320 xml = xml + "<arguments>";321 for ( var i=2; i<arguments.length; i++ )322 {323 // This should just be an argument to be passed to the324 // host ESP application.325 var ccArg = new CCAPIArgument( arguments[i] );326 xml = xml + ccArg.ToStringForCallCCFunction();327 }328 xml = xml + "</arguments>";329 } 330 xml = xml + "</invoke>";331 332 // Save the actual xml call string to be passed to the host ESP application333 espCall.XmlRequest = xml;334 335 // Push the call into the queue so ESP can call in to process it336 CCAPI.CallToESPQueue.push( espCall );337 338 // Return the ID for this call339 return callID;340}341342/*343 Method to navigate to a specified slide.344 345 slideId: String slide identifier (GUID) of slide to link to.346*/347function goToSlide( slideId )348{349 var callID = CCAPI.CallESPFunction(CCAPI.NAV_goToSlide, "myCallback", slideId);350 trace( "goToSlide callID=" + callID );351 trace( "goToSlide SlideID=" + slideId );352 //alert(slideId);353}354355/*356 Default trace method for debugging in browser.357 358 s: String to output to trace.359*/360function trace(s) {361 try { console.log(s) } catch (e) { 362 //alert(s); 363 }364};365366// Create an instance of the Content Communication API class so it will be initialized
...
InvokeNode.js
Source:InvokeNode.js
1/*2 * Copyright 2011 eBay Software Foundation3 *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 */16define.Class(17 'raptor/templating/taglibs/core/InvokeNode',18 'raptor/templating/compiler/Node',19 ['raptor'],20 function(raptor, require) {21 'use strict';22 23 var forEach = raptor.forEach;24 25 var InvokeNode = function(props) {26 InvokeNode.superclass.constructor.call(this);27 if (props) {28 this.setProperties(props);29 }30 };31 32 InvokeNode.prototype = {33 doGenerateCode: function(template) {34 35 var func = this.getProperty("function"),36 funcDef,37 bodyParam,38 definedFunctions = template.getAttribute("core:definedFunctions");39 40 if (!func) {41 this.addError('"function" attribute is required');42 return;43 }44 45 if (func.indexOf('(') === -1) {46 47 funcDef = definedFunctions ? definedFunctions[func] : null;48// if (!funcDef) {49// this.addError('Function with name "' + func + '" not defined using <c:define>.');50// }51 52 var argParts = [];53 var validParamsLookup = {};54 var params = [];55 56 if (funcDef) {57 params = funcDef.params || [];58 bodyParam = funcDef.bodyParam;59 /*60 * Loop over the defined parameters to figure out the names of allowed parameters and add them to a lookup61 */62 forEach(params, function(param) {63 validParamsLookup[param] = true;64 }, this);65 66 }67 var bodyArg = null;68 69 if (this.hasChildren()) {70 if (!funcDef || !funcDef.bodyParam) {71 this.addError('Nested content provided when invoking macro "' + func + '" but defined macro does not support nested content.');72 }73 else {74 bodyArg = this.getBodyContentExpression(template, false);75 }76 77 }78 /*79 * VALIDATION:80 * Loop over all of the provided attributes and make sure they are allowed 81 */82 this.forEachPropertyNS('', function(name, value) {83 if (name === 'function') {84 return;85 }86 87 if (!validParamsLookup[name]) {88 this.addError('Parameter with name "' + name + '" not supported for function with name "' + func + '". Allowed parameters: ' + params.join(", "));89 }90 }, this);91 92 /*93 * One more pass to build the argument list94 */95 forEach(params, function(param) {96 validParamsLookup[param] = true;97 if (param === bodyParam) {98 argParts.push(bodyArg ? bodyArg : "undefined");99 }100 else {101 var arg = this.getAttribute(param);102 if (arg == null) {103 argParts.push("undefined");104 }105 else {106 argParts.push(this.getProperty(param));107 }108 }109 110 }, this);111 112 template.write(func + "(" + argParts.join(",") + ")");113 }114 else {115 var funcName = func.substring(0, func.indexOf('('));116 funcDef = definedFunctions ? definedFunctions[funcName] : null;117 if (funcDef) {118 template.write(func);119 }120 else {121 template.statement(func + ";\n");122 }123 }124 }125 126 };127 128 return InvokeNode;...
changes.js
Source:changes.js
...81 refresh(repo);82}83function refresh(repo) {84 $ui.loading(true);85 bridge.invokeNode(repo, "statusMatrix", status => {86 const data = [];87 const convert = (type, path) => {88 return {89 "status-label": {90 "text": path,91 "path": path,92 "type": type93 }94 };95 }96 const push = (title, change, type) => {97 const rows = change.map(x => convert(type, x));98 if (rows.length > 0) {99 data.push({100 title: title,101 rows: rows102 });103 }104 }105 const array = isUnstagedTab() ? status.unstaged : status.staged;106 push("Added", array.added, "added");107 push("Modified", array.modified, "modified");108 push("Deleted", array.deleted, "deleted");109 const view = $("status-list");110 view.data = data;111 $ui.loading(false);112 });113}114function isUnstagedTab() {115 return $("state-tab").index === 0;116}117function diff(repo, path, type) {118 bridge.invokeNode(repo, "fileChanges", {119 path, type120 }, diffs => {121 const util = require("../util/rich-text");122 const viewer = require("./diff");123 viewer.open(util.build(diffs));124 });125}126function reset(repo, path, type) {127 bridge.invokeNode(repo, "resetFile", {128 path, type129 }, () => {130 $ui.toast("Done");131 refresh(repo);132 });133}134function stage(repo, path) {135 bridge.invokeNode(repo, "stage", {136 path: path137 }, () => {138 $ui.toast("Done");139 refresh(repo);140 });141}142function unstage(repo, path) {143 bridge.invokeNode(repo, "unstage", {144 path: path145 }, () => {146 $ui.toast("Done");147 refresh(repo);148 });149}150function stageAll(repo) {151 $ui.loading(true);152 bridge.invokeNode(repo, "stageAll", () => {153 $ui.loading(false);154 $ui.toast("Done");155 refresh(repo);156 });157}158function unstageAll(repo) {159 $ui.loading(true);160 bridge.invokeNode(repo, "unstageAll", () => {161 $ui.loading(false);162 $ui.toast("Done");163 refresh(repo);164 });165}166function resetAll(repo) {167 bridge.invokeNode(repo, "resetAll", () => {168 $ui.toast("Done");169 refresh(repo);170 });...
commits.js
Source:commits.js
...91 refresh(repo);92}93function refresh(repo) {94 $ui.loading(true);95 bridge.invokeNode(repo, "log", commits => {96 _commits = commits;97 const view = $("commits-list");98 view.data = commits.map(commit => {99 return {100 "message-line": {101 "text": commit.message102 },103 "commit-line": {104 "text": `commit ${commit.oid}`105 },106 "author-line": {107 "text": `Author: ${commit.author.name} <${commit.author.email}>`108 },109 "date-line": {110 "text": `${new Date(commit.author.timestamp * 1000)}`111 }112 }113 });114 $ui.loading(false);115 });116}117function changes(repo, commit) {118 const hash2 = commit.oid;119 const hash1 = commit.parent[0] || hash2;120 bridge.invokeNode(repo, "stateChanges", {121 hash1: hash1,122 hash2: hash2,123 }, results => {124 const stateChanges = require("./stateChanges");125 stateChanges.open(repo, hash1, hash2, results);126 });127}128function checkout(repo, commit) {129 bridge.invokeNode(repo, "checkout", {130 ref: commit.oid131 }, () => {132 $ui.toast("Done");133 });134}135function copySHA(repo, commit) {136 $clipboard.text = commit.oid;137 $ui.toast("Copied");138}139function softResetHEAD1(repo) {140 bridge.invokeNode(repo, "softReset", () => {141 $ui.toast("Done");142 refresh(repo);143 });...
multiple-runs.spec.js
Source:multiple-runs.spec.js
...4 it('should be allowed to run multiple times if cleanReferences is turned off', function(done) {5 var path = require.resolve(6 './fixtures/multiple-runs/run-thrice.fixture.js'7 );8 invokeNode([path], function(err, res) {9 if (err) {10 done(err);11 return;12 }13 expect(res.code, 'to be', 0);14 var results = JSON.parse(res.output);15 expect(results, 'to have length', 3);16 expect(results[0].pending, 'to have length', 1);17 expect(results[0].failures, 'to have length', 0);18 expect(results[0].passes, 'to have length', 0);19 expect(results[1].pending, 'to have length', 0);20 expect(results[1].failures, 'to have length', 1);21 expect(results[1].passes, 'to have length', 0);22 expect(results[2].pending, 'to have length', 0);23 expect(results[2].failures, 'to have length', 0);24 expect(results[2].passes, 'to have length', 1);25 done();26 });27 });28 it('should not be allowed if cleanReferences is true', function(done) {29 var path = require.resolve(30 './fixtures/multiple-runs/clean-references.fixture.js'31 );32 invokeNode(33 [path],34 function(err, res) {35 if (err) {36 done(err);37 return;38 }39 expect(res, 'to have failed').and(40 'to contain output',41 /ERR_MOCHA_INSTANCE_ALREADY_DISPOSED/42 );43 done();44 },45 {stdio: ['ignore', 'pipe', 'pipe']}46 );47 });48 it('should not be allowed if the instance is disposed', function(done) {49 var path = require.resolve('./fixtures/multiple-runs/dispose.fixture.js');50 invokeNode(51 [path, '--directly-dispose'],52 function(err, res) {53 if (err) {54 done(err);55 return;56 }57 expect(res.code, 'not to be', 0);58 expect(res.output, 'to contain', 'ERR_MOCHA_INSTANCE_ALREADY_DISPOSED');59 done();60 },61 {stdio: ['ignore', 'pipe', 'pipe']}62 );63 });64 it('should not be allowed to run while a previous run is in progress', function(done) {65 var path = require.resolve(66 './fixtures/multiple-runs/start-second-run-if-previous-is-still-running.fixture'67 );68 invokeNode(69 [path],70 function(err, res) {71 if (err) {72 done(err);73 return;74 }75 expect(res.output, 'to contain', 'ERR_MOCHA_INSTANCE_ALREADY_RUNNING');76 done();77 },78 {stdio: ['ignore', 'pipe', 'pipe']}79 );80 });81 it('should reset the hooks between runs', function(done) {82 var path = require.resolve(83 './fixtures/multiple-runs/multiple-runs-with-flaky-before-each.fixture'84 );85 invokeNode([path], function(err, res) {86 expect(err, 'to be null');87 expect(res.code, 'to be', 0);88 var results = JSON.parse(res.output);89 expect(results, 'to have length', 2);90 expect(results[0].failures, 'to have length', 1);91 expect(results[0].passes, 'to have length', 0);92 expect(results[1].passes, 'to have length', 1);93 expect(results[1].failures, 'to have length', 0);94 done();95 });96 });...
branches.js
Source:branches.js
...54 refresh(repo);55}56function refresh(repo) {57 $ui.loading(true);58 bridge.invokeNode(repo, "listBranches", null, results => {59 _branches = results.branches;60 const view = $("branch-list");61 view.data = results.branches.map(branch => {62 return {63 "branch-name": {64 "text": branch,65 "textColor": branch === results.current ? colors.selectedText : colors.defaultText66 }67 }68 });69 $ui.loading(false);70 });71}72function checkoutBranch(repo, branch) {73 bridge.invokeNode(repo, "checkout", {74 ref: branch75 }, () => {76 $ui.toast("Done");77 refresh(repo);78 });79}80function createBranch(repo) {81 $input.text({82 type: $kbType.ascii,83 placeholder: "Branch Name"84 }).then(name => {85 bridge.invokeNode(repo, "branch", {86 ref: name87 }, () => {88 $ui.toast("Done");89 refresh(repo);90 });91 });92}93function mergeBranch(repo, branch) {94 bridge.invokeNode(repo, "merge", {95 theirs: branch96 }, () => {97 $ui.toast("Done");98 });99}100function deleteBranch(repo, branch) {101 bridge.invokeNode(repo, "deleteBranch", {102 ref: branch103 }, () => {104 $ui.toast("Done");105 refresh(repo);106 });...
listRemotes.js
Source:listRemotes.js
...58 refresh(repo);59}60function refresh(repo) {61 $ui.loading(true);62 bridge.invokeNode(repo, "listRemotes", remotes => {63 states.remotes = remotes;64 $("remotes-list").data = remotes.map(item => {65 return {66 "label": {67 "text": `(${item.remote}) ${item.url}`68 }69 };70 });71 $ui.loading(false);72 });73}74function addRemote(repo) {75 const addRemote = require("./addRemote");76 addRemote(info => {77 bridge.invokeNode(repo, "addRemote", info, () => {78 refresh(repo);79 });80 });81}82function deleteRemote(repo, remote) {83 bridge.invokeNode(repo, "deleteRemote", {remote});...
tags.js
Source:tags.js
...38 refresh(repo);39}40function refresh(repo) {41 $ui.loading(true);42 bridge.invokeNode(repo, "listTags", (tags) => {43 states.tags = tags;44 $("tags-list").data = tags;45 $ui.loading(false);46 });47}48function addTag(repo) {49 $input.text({50 type: $kbType.ascii,51 placeholder: "Tag Name"52 }).then(tag => {53 bridge.invokeNode(repo, "tag", {54 ref: tag55 }, () => {56 $ui.toast("Done");57 refresh(repo);58 });59 });60}61function pushTag(repo, tag) {62 const push = require("./push");63 push(repo, tag);64}65function deleteTag(repo, tag) {66 bridge.invokeNode(repo, "deleteTag", {67 ref: tag68 }, () => {69 refresh(repo);70 });...
Using AI Code Generation
1var Mocha = require('mocha');2var mocha = new Mocha();3mocha.addFile('test.js');4mocha.run(function(failures){5 process.on('exit', function () {6 });7});8var Mocha = require('mocha');9var mocha = new Mocha();10mocha.addFile('test.js');11mocha.run(function(failures){12 process.on('exit', function () {13 });14});15var Mocha = require('mocha');16var mocha = new Mocha();17mocha.addFile('test.js');18mocha.run(function(failures){19 process.on('exit', function () {20 });21});22var Mocha = require('mocha');23var mocha = new Mocha();24mocha.addFile('test.js');25mocha.run(function(failures){26 process.on('exit', function () {27 });28});29var Mocha = require('mocha');30var mocha = new Mocha();31mocha.addFile('test.js');32mocha.run(function(failures){33 process.on('exit', function () {34 });35});36var Mocha = require('mocha');37var mocha = new Mocha();38mocha.addFile('test.js');39mocha.run(function(failures){40 process.on('exit', function () {41 });42});43var Mocha = require('mocha');44var mocha = new Mocha();45mocha.addFile('test.js');46mocha.run(function(failures){47 process.on('exit', function ()
Using AI Code Generation
1const Mocha = require('mocha');2const mocha = new Mocha();3mocha.addFile('test.js');4mocha.run(function(failures){5 process.on('exit', function () {6 });7});8const assert = require('assert');9describe('Array', function() {10 describe('#indexOf()', function() {11 it('should return -1 when the value is not present', function() {12 assert.equal([1,2,3].indexOf(4), -1);13 });14 });15});16mocha.run(function(failures){17 process.on('exit', function () {18 });19});20mocha.run(function(failures){21 process.on('exit', function () {22 done();23 });24});25mocha.run(function(failures){26 process.on('exit', function () {27 done();28 });29});30mocha.run(function
Using AI Code Generation
1var mocha = require('mocha');2var mocha = new mocha();3mocha.addFile('test.js');4mocha.run(function(failures){5 process.on('exit', function () {6 });7});
Using AI Code Generation
1var mocha = new Mocha();2mocha.addFile('/path/to/test/file.js');3mocha.run(function(failures){4 process.on('exit', function () {5 });6});7var mocha = new Mocha({8});9var mocha = new Mocha({10});11var mocha = new Mocha({12});13var mocha = new Mocha({14});15var mocha = new Mocha({16});17var mocha = new Mocha({18});19var mocha = new Mocha({20});21var mocha = new Mocha({22});23var mocha = new Mocha({24});25var mocha = new Mocha({26});27var mocha = new Mocha({28});29var mocha = new Mocha({30});
Using AI Code Generation
1var path = require('path');2var mocha = require('mocha');3var mocha = new mocha();4mocha.addFile(path.join(__dirname, 'test.js'));5mocha.run(function(failures){6 process.on('exit', function () {7 });8});9var assert = require('assert');10describe('Array', function() {11 describe('#indexOf()', function() {12 it('should return -1 when the value is not present', function() {13 assert.equal(-1, [1,2,3].indexOf(4));14 });15 });16});17var path = require('path');18var mocha = require('mocha');19var mocha = new mocha();20mocha.addFile(path.join(__dirname, 'test.js'));21mocha.run(function(failures){22 process.on('exit', function () {23 });24});25var assert = require('assert');26describe('Array', function() {27 describe('#indexOf()', function() {28 it('should return -1 when the value is not present', function() {29 assert.equal(-1, [1,2,3].indexOf(4));30 });31 });32});
Using AI Code Generation
1var Mocha = require('mocha');2var mocha = new Mocha({3 reporterOptions: {4 }5});6mocha.addFile('./test.js');7mocha.run(function(failures) {8 process.on('exit', function() {9 });10});
Using AI Code Generation
1var mocha = require('mocha');2var Mocha = new mocha({3});4Mocha.addFile('test.js');5Mocha.run(function(failures){6 process.on('exit', function () {7 });8});9{10 "stats": {11 },12 {13 "code": "it('Addition of two numbers', function() {expect(2+2).to.equal(4);});",14 "err": {},15 },16 {
Using AI Code Generation
1var invokeNode = require('mocha').invokeNode;2invokeNode(['test.js'], { opts: 'test/mocha.opts' }, function (err, result) {3 if (err) {4 console.log(err);5 }6 else {7 console.log(result);8 }9});
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!!