Best JavaScript code snippet using istanbul
widget.js
Source:widget.js
1/* @Autor::Nadson Fernando Silva de Oliveira @Email::nadsonfernando1@gmail.com*/2'use strict';3var _EVENTSINTERACTION,4 _PROPERTIES,5 _ANIMATION,6 _EVENTS = {};7exports.getValue = getValue;8exports.ANIMATION_UP = _upInteraction;9exports.ANIMATION_DOWN = _blurInteraction;10exports.setValue = setValue;11exports.listener = listener;12exports.blur = blur;13exports.focus = focus;14exports.clickIconAction = clickIconAction;15exports.setPasswordMask = setPasswordMask;16exports.setIconAction = setIconAction;17exports.setEditable = setEditable;18function _getController(controller) {19 return Widget.createController(controller);20}21function castBooleanForce(value) {22 return Boolean(eval(value));23}24function _upInteraction() {25 var _configuration = _PROPERTIES.get();26 if (!castBooleanForce(_configuration.control.isEditable))27 return;28 var color = _PROPERTIES.get('color');29 if (castBooleanForce(_configuration.control.isExceeding))30 color = _configuration.color.exceeding;31 if (!castBooleanForce(_configuration.control.isExceeding))32 color = _configuration.color.focus;33 var pathAnimation = 'animation.up.footer';34 if ($.args.animationType)35 pathAnimation += '.' + $.args.animationType;36 var footerProps = _PROPERTIES.get(pathAnimation);37 _PROPERTIES.set(pathAnimation + '.backgroundColor', color, true);38 _.defer(function() {39 _ANIMATION.animate($.footer, footerProps);40 });41 _PROPERTIES.set('animation.up.hint.color', color, true);42 _PROPERTIES.set('animation.up.hint.left', OS_ANDROID ? (-calculateHintSize() + 2) : -calculateHintSize(), true);43 _PROPERTIES.set('animation.up.hint.duration', _configuration.animationDuration, true);44 var hintProps = _PROPERTIES.get('animation.up.hint');45 hintProps.transform = Ti.UI.create2DMatrix({46 scale : 0.747 });48 _.defer(function() {49 _ANIMATION.animate($.hint, hintProps);50 });51 _PROPERTIES.set("control.isUp", true, true);52}53function _changeInteraction(event) {54 var _configuration = _PROPERTIES.get();55 var value = $.textfield.getValue().toString();56 if (castBooleanForce(_configuration.toUpperCase)) {57 $.textfield.setValue(value.toUpperCase());58 }59 if (_configuration.required) {60 if ($.textfield.getValue()) {61 $.required.setText("");62 controllExceeding(false);63 }64 }65 changeMask(event);66 if (_configuration.maxLength)67 minMaxLength(event, _configuration);68}69function _blurInteraction(event) {70 var _configuration = _PROPERTIES.get();71 if (!castBooleanForce(_configuration.control.isEditable))72 return;73 var color = _PROPERTIES.get('color');74 if (castBooleanForce(_configuration.control.isExceeding))75 color = _configuration.color.exceeding;76 if (!castBooleanForce(_configuration.control.isExceeding))77 color = _configuration.color.default;78 var pathAnimation = 'animation.down.footer';79 if ($.args.animationType)80 pathAnimation += '.' + $.args.animationType;81 var footerProps = _PROPERTIES.get(pathAnimation);82 _PROPERTIES.set(pathAnimation + '.backgroundColor', color, true);83 _.defer(function() {84 _ANIMATION.animate($.footer, footerProps, postionOverrideFooterAnimation);85 });86 var attrsHint = {87 top : $.textfield.getTop(),88 color : color,89 transform : Ti.UI.create2DMatrix().scale(1),90 left : 0,91 duration : _configuration.animationDuration92 };93 if ($.textfield.getValue()) {94 attrsHint.top = 0;95 attrsHint.transform = Ti.UI.create2DMatrix().scale(0.7);96 attrsHint.left = -calculateHintSize();97 }98 _ANIMATION.animate($.hint, attrsHint);99 _PROPERTIES.set("control.isUp", false, true);100 if (_configuration.maxLength)101 minMaxLength(event, _configuration);102 if (_configuration.required) {103 if (!$.textfield.getValue()) {104 $.required.setText(_configuration.required);105 controllExceeding(false);106 }107 }108}109function changeMask(event) {110 var source = event.source;111 var regExp;112 var messageDefault = '';113 114 if(_.isUndefined($.args.maskType))115 return;116 if ($.args.maskTypeOverride) {117 source.value = source.value.replace($.args.maskTypeOverride, '');118 return;119 }120 switch($.args.maskType) {121 case 'number':122 regExp = /^[\+\-]?\d*\.?\d+(?:[Ee][\+\-]?\d+)?$/;123 messageDefault = "Number invalid";124 break;125 126 case 'email':127 regExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;128 messageDefault = "E-mail invalid";129 break;130 }131 if (!regExp.test(source.value)) {132 $.required.setText(messageDefault || $.args.maskTypeDescription);133 } else {134 $.required.setText("");135 }136 if (!_.size(source.value))137 $.required.setText("");138}139function resetColorWarning() {140 var _configuration = _PROPERTIES.get();141 _PROPERTIES.set('control.isExceeding', false, true);142 $.footer.setBackgroundColor(_configuration.color.default);143 $.counter.setColor(_configuration.color.default);144 $.hint.setColor(_configuration.color.default);145}146function minMaxLength(event, properties) {147 var _configuration = properties;148 var eventSize = event.value.length;149 if (eventSize == 0 && !castBooleanForce(_configuration.control.isUp)) {150 _ANIMATION.animate($.counter, _configuration.animation.minMaxSizeTo);151 resetColorWarning();152 return;153 } else if (eventSize == 1) {154 _ANIMATION.animate($.counter, _configuration.animation.minSizeMaxBack);155 }156 if (eventSize < _configuration.minLength || eventSize > _configuration.maxLength)157 controllExceeding(true);158 else if ($.footer.getBackgroundColor() != _configuration.color.focus)159 controllExceeding(false);160 $.counter.setText(eventSize + " / " + _configuration.maxLength);161}162function controllExceeding(isExceeding) {163 var _configuration = _PROPERTIES.get();164 _PROPERTIES.set('control.isExceeding', eval(isExceeding), true);165 var colorExceedind = castBooleanForce(isExceeding) ? _configuration.color.exceeding : _configuration.color.focus;166 $.footer.setBackgroundColor(colorExceedind);167 $.counter.setColor(colorExceedind);168 $.hint.setColor(colorExceedind);169}170function calculateHintSize() {171 var sizeHint = _.size($.hint.getText());172 sizeHint += sizeHint * (Number(sizeHint) > 25 ? 0.2 : 0.1);173 return sizeHint;174}175function contructorElement() {176 var _configuration = _PROPERTIES.get();177 _configuration.width && $.container.setWidth(_configuration.width);178 _configuration.top && $.container.setTop(_configuration.top);179 _configuration.bottom && $.container.setBottom(_configuration.bottom);180 _configuration.left && $.container.setLeft(_configuration.left);181 _configuration.right && $.container.setRight(_configuration.right);182 _configuration.colorFont && $.textfield.setColor(_configuration.colorFont);183 _configuration.keyboardType && $.textfield.setKeyboardType(_configuration.keyboardType);184 _configuration.returnKey && $.textfield.setReturnKeyType(_configuration.returnKey);185 _configuration.password && $.textfield.setPasswordMask(_configuration.password);186 _configuration.colorDefault && $.hint.setColor(_configuration.colorDefault);187 _configuration.colorDefault && $.footer.setBackgroundColor(_configuration.colorDefault);188 _configuration.titleHint && $.hint.setText(_configuration.titleHint);189 _configuration.titleHintVisible && $.hint.setVisible(_configuration.titleHintVisible);190 _configuration.colorFocus && _PROPERTIES.set("color.focus", _configuration.colorFocus, true);191 _configuration.colorDefault && _PROPERTIES.set("color.default", _configuration.colorDefault, true);192 _configuration.colorExceeding && _PROPERTIES.set("color.exceeding", _configuration.colorDefault, true);193 $.hint.setColor(_configuration.color.default);194 $.footer.setBackgroundColor(_configuration.color.default);195 $.iconAction.setColor(_configuration.color.default);196 197 _configuration.control.isEditable = _configuration.editable || _configuration.control.isEditable;198 if (!castBooleanForce(_configuration.control.isEditable)) {199 $.container.setOpacity(0.3);200 $.textfield.setEditable(false);201 }202 postionOverrideFooterAnimation();203 if (!_.isUndefined($.args.iconAction)) {204 $.iconAction.setVisible(true);205 setIconAction($.args.iconAction);206 }207}208function postionOverrideFooterAnimation() {209 switch($.args.animationType) {210 case 'leftToRight':211 case 'leftToRightToRightOut':212 $.footer.setRight("100%");213 break;214 case 'expand':215 $.footer.setWidth(0.1);216 break; 217 }218}219(function(args) {220 _EVENTSINTERACTION = _getController('_eventsInteraction');221 _PROPERTIES = _getController('_properties');222 _ANIMATION = _getController('_animation');223 _PROPERTIES.apply(args);224 _PROPERTIES.set('animation', _ANIMATION.getPropertiesConfig());225 contructorElement(args);226 _EVENTS = _PROPERTIES.get('EVENTS');227 _EVENTSINTERACTION.listener($.textfield, _EVENTS.FOCUS, _upInteraction);228 _EVENTSINTERACTION.listener($.textfield, _EVENTS.CHANGE, _changeInteraction);229 _EVENTSINTERACTION.listener($.textfield, _EVENTS.BLUR, _blurInteraction);230}($.args));231function getValue() {232 return $.textfield.getValue();233}234function setValue(value, uping) {235 if (uping)236 _upInteraction();237 $.textfield.setValue(value);238}239function setEditable(value) {240 _PROPERTIES.set("control.isEditable", value, true);241 $.container.setOpacity(1);242 $.textfield.setEditable(value);243}244function listener(event, callback) {245 $.textfield.addEventListener(event, function(e) {246 callback(e);247 });248};249function blur(toFocus) {250 $.textfield.blur();251};252function focus() {253 $.textfield.focus();254};255function clickIconAction(_callbackIconAction) {256 if (!$.args.iconAction)257 return;258 _EVENTSINTERACTION.listener($.iconAction, _EVENTS.CLICK, _callbackIconAction);259}260function setPasswordMask(value) {261 $.textfield.setPasswordMask(value);262}263function setIconAction(value) {264 $.iconAction.setText(value);...
VSDService.js
Source:VSDService.js
...36 }37 return entity;38 }39 getRequestID = (configuration, context = {}) => {40 const tmpConfiguration = NUTemplateParser.parameterizedConfiguration(configuration, context);41 if (!tmpConfiguration)42 return;43 let endPoint = tmpConfiguration.query.parentResource;44 if (tmpConfiguration.query.hasOwnProperty("parentID"))45 endPoint += "/" + tmpConfiguration.query.parentID;46 if (tmpConfiguration.query.hasOwnProperty("resource"))47 endPoint += "/" + tmpConfiguration.query.resource;48 endPoint = configuration.id ? `${configuration.vizID}-${configuration.id}-${endPoint}` : endPoint;49 if (!tmpConfiguration.query.filter) {50 return endPoint;51 }52 return endPoint + "-" + tmpConfiguration.query.filter;53 }54 /**...
nightwatch.conf.js
Source:nightwatch.conf.js
1var SELENIUM_CONFIGURATION = {2 start_process: true,3 server_path: './node_modules/selenium-standalone/.selenium/selenium-server/3.4.0-server.jar',4};5var FIREFOX_CONFIGURATION = {6 browserName: 'firefox',7 javascriptEnabled: true,8 acceptSslCerts: true,9 marionette: true,10};11var CHROME_CONFIGURATION = {12 browserName: 'chrome',13 javascriptEnabled: true,14 acceptSslCerts: true15};16var IE_CONFIGURATION = {17 browserName: 'internet explorer',18 javascriptEnabled: true,19 acceptSslCerts: true20};21var DEFAULT_CONFIGURATION = {22 launch_url: 'http://automationpractice.com/index.php',23 selenium_port: 4444,24 selenium_host: 'localhost',25 end_session_on_fail: true,26 skip_testcases_on_fail: false,27 desiredCapabilities: FIREFOX_CONFIGURATION,28 cli_args: {29 "webdriver.chrome.driver": "./node_modules/selenium-standalone/.selenium/chromedriver/2.30-x64-chromedriver",30 "webdriver.firefox.marionette": "./node_modules/selenium-standalone/.selenium/geckodriver/0.16.1-x64-geckodriver",31 "webdriver.edge.driver": "",32 "webdriver.ie.driver": "./node_modules/selenium-standalone/.selenium/iedriver/IEDriverServer.exe",33 "nightwatch-html-reporter": "-d /reports [--theme (default:'default')] [--output (default:generatedReport.html)]"34 },35};36var UAT_ENV_FIREFOX_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {37 launch_url: 'http://automationpractice.com/index.php',38 desiredCapabilities: FIREFOX_CONFIGURATION39});40var UAT_ENV_CHROME_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {41 launch_url: 'http://automationpractice.com/index.php',42 desiredCapabilities: CHROME_CONFIGURATION43});44var UAT_EN_INERNET_EXPLORER_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {45 launch_url: 'http://automationpractice.com/index.php',46 desiredCapabilities: IE_CONFIGURATION47});48var TEST_ENV_FIREFOX_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {49 launch_url: 'http://automationpractice.com/index.php',50 desiredCapabilities: FIREFOX_CONFIGURATION51});52var TEST_ENV_CHROME_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {53 launch_url: 'http://automationpractice.com/index.php',54 desiredCapabilities: CHROME_CONFIGURATION55});56var TEST_ENV_INTERNET_EXPLORER_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {57 launch_url: 'http://automationpractice.com/index.php',58 desiredCapabilities: IE_CONFIGURATION59});60var SIT_ENV_FIREFOX_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {61 launch_url: 'http://automationpractice.com/index.php',62 desiredCapabilities: FIREFOX_CONFIGURATION63});64var SIT_ENV_CHROME_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {65 launch_url: 'http://automationpractice.com/index.php',66 desiredCapabilities: CHROME_CONFIGURATION67});68var SIT_ENV_INTERNET_EXPLORER_CONFIGURATION = Object.assign({}, DEFAULT_CONFIGURATION, {69 launch_url: 'http://automationpractice.com/index.php',70 desiredCapabilities: IE_CONFIGURATION71});72var ENVIRONMENTS = {73 default: DEFAULT_CONFIGURATION,74 test_firefox: TEST_ENV_FIREFOX_CONFIGURATION,75 test_chrome: TEST_ENV_CHROME_CONFIGURATION,76 test_ie: TEST_ENV_INTERNET_EXPLORER_CONFIGURATION,77 uat_firefox: UAT_ENV_FIREFOX_CONFIGURATION,78 uat_chrome: UAT_ENV_CHROME_CONFIGURATION,79 uat_ie: UAT_EN_INERNET_EXPLORER_CONFIGURATION,80 sit_firefox:SIT_ENV_FIREFOX_CONFIGURATION,81 sit_chrome:SIT_ENV_CHROME_CONFIGURATION,82 sit_ie:SIT_ENV_INTERNET_EXPLORER_CONFIGURATION,83};84module.exports = {85 src_folders: ['tests'],86 selenium: SELENIUM_CONFIGURATION,87 test_settings: ENVIRONMENTS...
Using AI Code Generation
1var istanbul = require('istanbul');2var config = istanbul.config.loadFile('./.istanbul.yml');3var collector = new istanbul.Collector();4var reporter = new istanbul.Reporter(false, './coverage');5var coverage = istanbul.utils.summarizeCoverage(collector.getFinalCoverage());6reporter.addAll(config.reporting.reports);7reporter.write(coverage, true, function() {8 console.log('done');9});10var instrumenter = new istanbul.Instrumenter(config.instrumenter);11var fs = require('fs');12var code = fs.readFileSync('test.js', 'utf8');13var instrumentedCode = instrumenter.instrumentSync(code, 'test.js');14fs.writeFileSync('test.js', instrumentedCode);15var hook = istanbul.hook;16hook.hookRequire();17hook.hookRunInThisContext();18hook.hookRunInContext();
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var sync = false;5var istanbul = require('istanbul');6var collector = new istanbul.Collector();7var reporter = new istanbul.Reporter();8var sync = false;9var istanbul = require('istanbul');10var collector = new istanbul.Collector();11var reporter = new istanbul.Reporter();12var sync = false;13var istanbul = require('istanbul');14var collector = new istanbul.Collector();15var reporter = new istanbul.Reporter();16var sync = false;17var istanbul = require('istanbul');18var collector = new istanbul.Collector();19var reporter = new istanbul.Reporter();20var sync = false;21var istanbul = require('istanbul');22var collector = new istanbul.Collector();23var reporter = new istanbul.Reporter();24var sync = false;25var istanbul = require('istanbul');26var collector = new istanbul.Collector();27var reporter = new istanbul.Reporter();28var sync = false;29var istanbul = require('istanbul');30var collector = new istanbul.Collector();31var reporter = new istanbul.Reporter();32var sync = false;33var istanbul = require('istanbul');34var collector = new istanbul.Collector();35var reporter = new istanbul.Reporter();36var sync = false;37var istanbul = require('istanbul');38var collector = new istanbul.Collector();39var reporter = new istanbul.Reporter();40var sync = false;41var istanbul = require('istanbul');42var collector = new istanbul.Collector();
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var istanbul = require('istanbul');5var collector = new istanbul.Collector();6var reporter = new istanbul.Reporter();7var istanbul = require('istanbul');8var collector = new istanbul.Collector();9var reporter = new istanbul.Reporter();10var istanbul = require('istanbul');11var collector = new istanbul.Collector();12var reporter = new istanbul.Reporter();13var istanbul = require('istanbul');14var collector = new istanbul.Collector();15var reporter = new istanbul.Reporter();16var istanbul = require('istanbul');17var collector = new istanbul.Collector();18var reporter = new istanbul.Reporter();19var istanbul = require('istanbul');20var collector = new istanbul.Collector();21var reporter = new istanbul.Reporter();22var istanbul = require('istanbul');23var collector = new istanbul.Collector();24var reporter = new istanbul.Reporter();25var istanbul = require('istanbul');26var collector = new istanbul.Collector();27var reporter = new istanbul.Reporter();28var istanbul = require('istanbul');29var collector = new istanbul.Collector();30var reporter = new istanbul.Reporter();31var istanbul = require('istanbul');32var collector = new istanbul.Collector();33var reporter = new istanbul.Reporter();34var istanbul = require('istanbul');35var collector = new istanbul.Collector();36var reporter = new istanbul.Reporter();
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3collector.add(__coverage__ || {});4var reporter = new istanbul.Reporter();5var sync = true;6reporter.addAll(['text-summary', 'lcov', 'html']);7reporter.write(collector, sync, function () {8 console.log('All reports generated');9});10coverageIstanbulReporter: {11 dir: require('path').join(__dirname, '../coverage'),12 }13Chrome 76.0.3809 (Windows 10.0.0): Executed 11 of 11 SUCCESS (0.24 secs / 0.197 secs)14coverageIstanbulReporter: {15 dir: require('path').join(__dirname, '../coverage'),16 }17Chrome 76.0.3809 (Windows 10.0.0): Executed 11 of 11 SUCCESS (0.24 secs / 0.197 secs)
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!!