How to use preprocessor method in Cypress

Best JavaScript code snippet using cypress

knockout.punches.js

Source:knockout.punches.js Github

copy

Full Screen

1/**2 * @license Knockout.Punches3 * Enhanced binding syntaxes for Knockout 3+4 * (c) Michael Best5 * License: MIT (http://www.opensource.org/licenses/mit-license.php)6 * Version 0.5.17 */8(function (factory) {9 if (typeof define === 'function' && define.amd) {10 // AMD. Register as an anonymous module.11 define(['knockout'], factory);12 } else if (typeof module === "object") {13 // CommonJS module14 var ko = require("knockout");15 factory(ko);16 } else {17 // Browser globals18 factory(window.ko);19 }20}(function(ko) {21// Add a preprocess function to a binding handler.22function addBindingPreprocessor(bindingKeyOrHandler, preprocessFn) {23 return chainPreprocessor(getOrCreateHandler(bindingKeyOrHandler), 'preprocess', preprocessFn);24}25// These utility functions are separated out because they're also used by26// preprocessBindingProperty27// Get the binding handler or create a new, empty one28function getOrCreateHandler(bindingKeyOrHandler) {29 return typeof bindingKeyOrHandler === 'object' ? bindingKeyOrHandler :30 (ko.getBindingHandler(bindingKeyOrHandler) || (ko.bindingHandlers[bindingKeyOrHandler] = {}));31}32// Add a preprocess function33function chainPreprocessor(obj, prop, fn) {34 if (obj[prop]) {35 // If the handler already has a preprocess function, chain the new36 // one after the existing one. If the previous function in the chain37 // returns a falsy value (to remove the binding), the chain ends. This38 // method allows each function to modify and return the binding value.39 var previousFn = obj[prop];40 obj[prop] = function(value, binding, addBinding) {41 value = previousFn.call(this, value, binding, addBinding);42 if (value)43 return fn.call(this, value, binding, addBinding);44 };45 } else {46 obj[prop] = fn;47 }48 return obj;49}50// Add a preprocessNode function to the binding provider. If a51// function already exists, chain the new one after it. This calls52// each function in the chain until one modifies the node. This53// method allows only one function to modify the node.54function addNodePreprocessor(preprocessFn) {55 var provider = ko.bindingProvider.instance;56 if (provider.preprocessNode) {57 var previousPreprocessFn = provider.preprocessNode;58 provider.preprocessNode = function(node) {59 var newNodes = previousPreprocessFn.call(this, node);60 if (!newNodes)61 newNodes = preprocessFn.call(this, node);62 return newNodes;63 };64 } else {65 provider.preprocessNode = preprocessFn;66 }67}68function addBindingHandlerCreator(matchRegex, callbackFn) {69 var oldGetHandler = ko.getBindingHandler;70 ko.getBindingHandler = function(bindingKey) {71 var match;72 return oldGetHandler(bindingKey) || ((match = bindingKey.match(matchRegex)) && callbackFn(match, bindingKey));73 };74}75// Create shortcuts to commonly used ko functions76var ko_unwrap = ko.unwrap;77// Create "punches" object and export utility functions78var ko_punches = ko.punches = {79 utils: {80 addBindingPreprocessor: addBindingPreprocessor,81 addNodePreprocessor: addNodePreprocessor,82 addBindingHandlerCreator: addBindingHandlerCreator,83 // previous names retained for backwards compitibility84 setBindingPreprocessor: addBindingPreprocessor,85 setNodePreprocessor: addNodePreprocessor86 }87};88ko_punches.enableAll = function () {89 // Enable interpolation markup90 enableInterpolationMarkup();91 enableAttributeInterpolationMarkup();92 // Enable auto-namspacing of attr, css, event, and style93 enableAutoNamespacedSyntax('attr');94 enableAutoNamespacedSyntax('css');95 enableAutoNamespacedSyntax('event');96 enableAutoNamespacedSyntax('style');97 // Make sure that Knockout knows to bind checked after attr.value (see #40)98 ko.bindingHandlers.checked.after.push('attr.value');99 // Enable filter syntax for text, html, and attr100 enableTextFilter('text');101 enableTextFilter('html');102 addDefaultNamespacedBindingPreprocessor('attr', filterPreprocessor);103 // Enable wrapped callbacks for click, submit, event, optionsAfterRender, and template options104 enableWrappedCallback('click');105 enableWrappedCallback('submit');106 enableWrappedCallback('optionsAfterRender');107 addDefaultNamespacedBindingPreprocessor('event', wrappedCallbackPreprocessor);108 addBindingPropertyPreprocessor('template', 'beforeRemove', wrappedCallbackPreprocessor);109 addBindingPropertyPreprocessor('template', 'afterAdd', wrappedCallbackPreprocessor);110 addBindingPropertyPreprocessor('template', 'afterRender', wrappedCallbackPreprocessor);111};112// Convert input in the form of `expression | filter1 | filter2:arg1:arg2` to a function call format113// with filters accessed as ko.filters.filter1, etc.114function filterPreprocessor(input) {115 // Check if the input contains any | characters; if not, just return116 if (input.indexOf('|') === -1)117 return input;118 // Split the input into tokens, in which | and : are individual tokens, quoted strings are ignored, and all tokens are space-trimmed119 var tokens = input.match(/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|\|\||[|:]|[^\s|:"'][^|:"']*[^\s|:"']|[^\s|:"']/g);120 if (tokens && tokens.length > 1) {121 // Append a line so that we don't need a separate code block to deal with the last item122 tokens.push('|');123 input = tokens[0];124 var lastToken, token, inFilters = false, nextIsFilter = false;125 for (var i = 1, token; token = tokens[i]; ++i) {126 if (token === '|') {127 if (inFilters) {128 if (lastToken === ':')129 input += "undefined";130 input += ')';131 }132 nextIsFilter = true;133 inFilters = true;134 } else {135 if (nextIsFilter) {136 input = "ko.filters['" + token + "'](" + input;137 } else if (inFilters && token === ':') {138 if (lastToken === ':')139 input += "undefined";140 input += ",";141 } else {142 input += token;143 }144 nextIsFilter = false;145 }146 lastToken = token;147 }148 }149 return input;150}151// Set the filter preprocessor for a specific binding152function enableTextFilter(bindingKeyOrHandler) {153 addBindingPreprocessor(bindingKeyOrHandler, filterPreprocessor);154}155var filters = {};156// Convert value to uppercase157filters.uppercase = function(value) {158 return String.prototype.toUpperCase.call(ko_unwrap(value));159};160// Convert value to lowercase161filters.lowercase = function(value) {162 return String.prototype.toLowerCase.call(ko_unwrap(value));163};164// Return default value if the input value is empty or null165filters['default'] = function (value, defaultValue) {166 value = ko_unwrap(value);167 if (typeof value === "function") {168 return value;169 }170 if (typeof value === "string") {171 return trim(value) === '' ? defaultValue : value;172 }173 return value == null || value.length == 0 ? defaultValue : value;174};175// Return the value with the search string replaced with the replacement string176filters.replace = function(value, search, replace) {177 return String.prototype.replace.call(ko_unwrap(value), search, replace);178};179filters.fit = function(value, length, replacement, trimWhere) {180 value = ko_unwrap(value);181 if (length && ('' + value).length > length) {182 replacement = '' + (replacement || '...');183 length = length - replacement.length;184 value = '' + value;185 switch (trimWhere) {186 case 'left':187 return replacement + value.slice(-length);188 case 'middle':189 var leftLen = Math.ceil(length / 2);190 return value.substr(0, leftLen) + replacement + value.slice(leftLen-length);191 default:192 return value.substr(0, length) + replacement;193 }194 } else {195 return value;196 }197};198// Convert a model object to JSON199filters.json = function(rootObject, space, replacer) { // replacer and space are optional200 return ko.toJSON(rootObject, replacer, space);201};202// Format a number using the browser's toLocaleString203filters.number = function(value) {204 return (+ko_unwrap(value)).toLocaleString();205};206// Export the filters object for general access207ko.filters = filters;208// Export the preprocessor functions209ko_punches.textFilter = {210 preprocessor: filterPreprocessor,211 enableForBinding: enableTextFilter212};213// Support dynamically-created, namespaced bindings. The binding key syntax is214// "namespace.binding". Within a certain namespace, we can dynamically create the215// handler for any binding. This is particularly useful for bindings that work216// the same way, but just set a different named value, such as for element217// attributes or CSS classes.218var namespacedBindingMatch = /([^\.]+)\.(.+)/, namespaceDivider = '.';219addBindingHandlerCreator(namespacedBindingMatch, function (match, bindingKey) {220 var namespace = match[1],221 namespaceHandler = ko.bindingHandlers[namespace];222 if (namespaceHandler) {223 var bindingName = match[2],224 handlerFn = namespaceHandler.getNamespacedHandler || defaultGetNamespacedHandler,225 handler = handlerFn.call(namespaceHandler, bindingName, namespace, bindingKey);226 ko.bindingHandlers[bindingKey] = handler;227 return handler;228 }229});230// Knockout's built-in bindings "attr", "event", "css" and "style" include the idea of231// namespaces, representing it using a single binding that takes an object map of names232// to values. This default handler translates a binding of "namespacedName: value"233// to "namespace: {name: value}" to automatically support those built-in bindings.234function defaultGetNamespacedHandler(name, namespace, namespacedName) {235 var handler = ko.utils.extend({}, this);236 function setHandlerFunction(funcName) {237 if (handler[funcName]) {238 handler[funcName] = function(element, valueAccessor) {239 function subValueAccessor() {240 var result = {};241 result[name] = valueAccessor();242 return result;243 }244 var args = Array.prototype.slice.call(arguments, 0);245 args[1] = subValueAccessor;246 return ko.bindingHandlers[namespace][funcName].apply(this, args);247 };248 }249 }250 // Set new init and update functions that wrap the originals251 setHandlerFunction('init');252 setHandlerFunction('update');253 // Clear any preprocess function since preprocessing of the new binding would need to be different254 if (handler.preprocess)255 handler.preprocess = null;256 if (ko.virtualElements.allowedBindings[namespace])257 ko.virtualElements.allowedBindings[namespacedName] = true;258 return handler;259}260// Adds a preprocess function for every generated namespace.x binding. This can261// be called multiple times for the same binding, and the preprocess functions will262// be chained. If the binding has a custom getNamespacedHandler method, make sure that263// it's set before this function is used.264function addDefaultNamespacedBindingPreprocessor(namespace, preprocessFn) {265 var handler = ko.getBindingHandler(namespace);266 if (handler) {267 var previousHandlerFn = handler.getNamespacedHandler || defaultGetNamespacedHandler;268 handler.getNamespacedHandler = function() {269 return addBindingPreprocessor(previousHandlerFn.apply(this, arguments), preprocessFn);270 };271 }272}273function autoNamespacedPreprocessor(value, binding, addBinding) {274 if (value.charAt(0) !== "{")275 return value;276 // Handle two-level binding specified as "binding: {key: value}" by parsing inner277 // object and converting to "binding.key: value"278 var subBindings = ko.expressionRewriting.parseObjectLiteral(value);279 ko.utils.arrayForEach(subBindings, function(keyValue) {280 addBinding(binding + namespaceDivider + keyValue.key, keyValue.value);281 });282}283// Set the namespaced preprocessor for a specific binding284function enableAutoNamespacedSyntax(bindingKeyOrHandler) {285 addBindingPreprocessor(bindingKeyOrHandler, autoNamespacedPreprocessor);286}287// Export the preprocessor functions288ko_punches.namespacedBinding = {289 defaultGetHandler: defaultGetNamespacedHandler,290 setDefaultBindingPreprocessor: addDefaultNamespacedBindingPreprocessor, // for backwards compat.291 addDefaultBindingPreprocessor: addDefaultNamespacedBindingPreprocessor,292 preprocessor: autoNamespacedPreprocessor,293 enableForBinding: enableAutoNamespacedSyntax294};295// Wrap a callback function in an anonymous function so that it is called with the appropriate296// "this" value.297function wrappedCallbackPreprocessor(val) {298 // Matches either an isolated identifier or something ending with a property accessor299 if (/^([$_a-z][$\w]*|.+(\.\s*[$_a-z][$\w]*|\[.+\]))$/i.test(val)) {300 return 'function(_x,_y,_z){return(' + val + ')(_x,_y,_z);}';301 } else {302 return val;303 }304}305// Set the wrappedCallback preprocessor for a specific binding306function enableWrappedCallback(bindingKeyOrHandler) {307 addBindingPreprocessor(bindingKeyOrHandler, wrappedCallbackPreprocessor);308}309// Export the preprocessor functions310ko_punches.wrappedCallback = {311 preprocessor: wrappedCallbackPreprocessor,312 enableForBinding: enableWrappedCallback313};314// Attach a preprocess function to a specific property of a binding. This allows you to315// preprocess binding "options" using the same preprocess functions that work for bindings.316function addBindingPropertyPreprocessor(bindingKeyOrHandler, property, preprocessFn) {317 var handler = getOrCreateHandler(bindingKeyOrHandler);318 if (!handler._propertyPreprocessors) {319 // Initialize the binding preprocessor320 chainPreprocessor(handler, 'preprocess', propertyPreprocessor);321 handler._propertyPreprocessors = {};322 }323 // Add the property preprocess function324 chainPreprocessor(handler._propertyPreprocessors, property, preprocessFn);325}326// In order to preprocess a binding property, we have to preprocess the binding itself.327// This preprocess function splits up the binding value and runs each property's preprocess328// function if it's set.329function propertyPreprocessor(value, binding, addBinding) {330 if (value.charAt(0) !== "{")331 return value;332 var subBindings = ko.expressionRewriting.parseObjectLiteral(value),333 resultStrings = [],334 propertyPreprocessors = this._propertyPreprocessors || {};335 ko.utils.arrayForEach(subBindings, function(keyValue) {336 var prop = keyValue.key, propVal = keyValue.value;337 if (propertyPreprocessors[prop]) {338 propVal = propertyPreprocessors[prop](propVal, prop, addBinding);339 }340 if (propVal) {341 resultStrings.push("'" + prop + "':" + propVal);342 }343 });344 return "{" + resultStrings.join(",") + "}";345}346// Export the preprocessor functions347ko_punches.preprocessBindingProperty = {348 setPreprocessor: addBindingPropertyPreprocessor, // for backwards compat.349 addPreprocessor: addBindingPropertyPreprocessor350};351// Wrap an expression in an anonymous function so that it is called when the event happens352function makeExpressionCallbackPreprocessor(args) {353 return function expressionCallbackPreprocessor(val) {354 return 'function('+args+'){return(' + val + ');}';355 };356}357var eventExpressionPreprocessor = makeExpressionCallbackPreprocessor("$data,$event");358// Set the expressionCallback preprocessor for a specific binding359function enableExpressionCallback(bindingKeyOrHandler, args) {360 var args = Array.prototype.slice.call(arguments, 1).join();361 addBindingPreprocessor(bindingKeyOrHandler, makeExpressionCallbackPreprocessor(args));362}363// Export the preprocessor functions364ko_punches.expressionCallback = {365 makePreprocessor: makeExpressionCallbackPreprocessor,366 eventPreprocessor: eventExpressionPreprocessor,367 enableForBinding: enableExpressionCallback368};369// Create an "on" namespace for events to use the expression method370ko.bindingHandlers.on = {371 getNamespacedHandler: function(eventName) {372 var handler = ko.getBindingHandler('event' + namespaceDivider + eventName);373 return addBindingPreprocessor(handler, eventExpressionPreprocessor);374 }375};376// Performance comparison at http://jsperf.com/markup-interpolation-comparison377function parseInterpolationMarkup(textToParse, outerTextCallback, expressionCallback) {378 function innerParse(text) {379 var innerMatch = text.match(/^([\s\S]*)}}([\s\S]*?)\{\{([\s\S]*)$/);380 if (innerMatch) {381 innerParse(innerMatch[1]);382 outerTextCallback(innerMatch[2]);383 expressionCallback(innerMatch[3]);384 } else {385 expressionCallback(text);386 }387 }388 var outerMatch = textToParse.match(/^([\s\S]*?)\{\{([\s\S]*)}}([\s\S]*)$/);389 if (outerMatch) {390 outerTextCallback(outerMatch[1]);391 innerParse(outerMatch[2]);392 outerTextCallback(outerMatch[3]);393 }394}395function trim(string) {396 return string == null ? '' :397 string.trim ?398 string.trim() :399 string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');400}401function interpolationMarkupPreprocessor(node) {402 // only needs to work with text nodes403 if (node.nodeType === 3 && node.nodeValue && node.nodeValue.indexOf('{{') !== -1 && (node.parentNode || {}).nodeName != "TEXTAREA") {404 var nodes = [];405 function addTextNode(text) {406 if (text)407 nodes.push(document.createTextNode(text));408 }409 function wrapExpr(expressionText) {410 if (expressionText)411 nodes.push.apply(nodes, ko_punches_interpolationMarkup.wrapExpression(expressionText, node));412 }413 parseInterpolationMarkup(node.nodeValue, addTextNode, wrapExpr)414 if (nodes.length) {415 if (node.parentNode) {416 for (var i = 0, n = nodes.length, parent = node.parentNode; i < n; ++i) {417 parent.insertBefore(nodes[i], node);418 }419 parent.removeChild(node);420 }421 return nodes;422 }423 }424}425if (!ko.virtualElements.allowedBindings.html) {426 // Virtual html binding427 // SO Question: http://stackoverflow.com/a/15348139428 var overridden = ko.bindingHandlers.html.update;429 ko.bindingHandlers.html.update = function (element, valueAccessor) {430 if (element.nodeType === 8) {431 var html = ko_unwrap(valueAccessor());432 if (html != null) {433 var parsedNodes = ko.utils.parseHtmlFragment('' + html);434 ko.virtualElements.setDomNodeChildren(element, parsedNodes);435 } else {436 ko.virtualElements.emptyNode(element);437 }438 } else {439 overridden(element, valueAccessor);440 }441 };442 ko.virtualElements.allowedBindings.html = true;443}444function wrapExpression(expressionText, node) {445 var ownerDocument = node ? node.ownerDocument : document,446 closeComment = true,447 binding,448 expressionText = trim(expressionText),449 firstChar = expressionText[0],450 lastChar = expressionText[expressionText.length - 1],451 result = [],452 matches;453 if (firstChar === '#') {454 if (lastChar === '/') {455 binding = expressionText.slice(1, -1);456 } else {457 binding = expressionText.slice(1);458 closeComment = false;459 }460 if (matches = binding.match(/^([^,"'{}()\/:[\]\s]+)\s+([^\s:].*)/)) {461 binding = matches[1] + ':' + matches[2];462 }463 } else if (firstChar === '/') {464 // replace only with a closing comment465 } else if (firstChar === '{' && lastChar === '}') {466 binding = "html:" + trim(expressionText.slice(1, -1));467 } else {468 binding = "text:" + trim(expressionText);469 }470 if (binding)471 result.push(ownerDocument.createComment("ko " + binding));472 if (closeComment)473 result.push(ownerDocument.createComment("/ko"));474 return result;475};476function enableInterpolationMarkup() {477 addNodePreprocessor(interpolationMarkupPreprocessor);478}479// Export the preprocessor functions480var ko_punches_interpolationMarkup = ko_punches.interpolationMarkup = {481 preprocessor: interpolationMarkupPreprocessor,482 enable: enableInterpolationMarkup,483 wrapExpression: wrapExpression484};485var dataBind = 'data-bind';486function attributeInterpolationMarkerPreprocessor(node) {487 if (node.nodeType === 1 && node.attributes.length) {488 var dataBindAttribute = node.getAttribute(dataBind);489 for (var attrs = ko.utils.arrayPushAll([], node.attributes), n = attrs.length, i = 0; i < n; ++i) {490 var attr = attrs[i];491 if (attr.specified && attr.name != dataBind && attr.value.indexOf('{{') !== -1) {492 var parts = [], attrValue = '';493 function addText(text) {494 if (text)495 parts.push('"' + text.replace(/"/g, '\\"') + '"');496 }497 function addExpr(expressionText) {498 if (expressionText) {499 attrValue = expressionText;500 parts.push('ko.unwrap(' + expressionText + ')');501 }502 }503 parseInterpolationMarkup(attr.value, addText, addExpr);504 if (parts.length > 1) {505 attrValue = '""+' + parts.join('+');506 }507 if (attrValue) {508 var attrName = attr.name.toLowerCase();509 var attrBinding = ko_punches_attributeInterpolationMarkup.attributeBinding(attrName, attrValue, node) || attributeBinding(attrName, attrValue, node);510 if (!dataBindAttribute) {511 dataBindAttribute = attrBinding512 } else {513 dataBindAttribute += ',' + attrBinding;514 }515 node.setAttribute(dataBind, dataBindAttribute);516 // Using removeAttribute instead of removeAttributeNode because IE clears the517 // class if you use removeAttributeNode to remove the id.518 node.removeAttribute(attr.name);519 }520 }521 }522 }523}524function attributeBinding(name, value, node) {525 if (ko.getBindingHandler(name)) {526 return name + ':' + value;527 } else {528 return 'attr.' + name + ':' + value;529 }530}531function enableAttributeInterpolationMarkup() {532 addNodePreprocessor(attributeInterpolationMarkerPreprocessor);533}534var ko_punches_attributeInterpolationMarkup = ko_punches.attributeInterpolationMarkup = {535 preprocessor: attributeInterpolationMarkerPreprocessor,536 enable: enableAttributeInterpolationMarkup,537 attributeBinding: attributeBinding538};539 return ko_punches;...

Full Screen

Full Screen

run_plugins_spec.js

Source:run_plugins_spec.js Github

copy

Full Screen

1require('../../../spec_helper')2const _ = require('lodash')3const snapshot = require('snap-shot-it')4const Promise = require('bluebird')5const preprocessor = require(`${root}../../lib/plugins/child/preprocessor`)6const task = require(`${root}../../lib/plugins/child/task`)7const util = require(`${root}../../lib/plugins/util`)8const resolve = require(`${root}../../lib/util/resolve`)9const browserUtils = require(`${root}../../lib/browsers/utils`)10const Fixtures = require(`${root}../../test/support/helpers/fixtures`)11const tsNodeUtil = require(`${root}../../lib/plugins/child/ts_node`)12const runPlugins = require(`${root}../../lib/plugins/child/run_plugins`)13const colorCodeRe = /\[[0-9;]+m/gm14const pathRe = /\/?([a-z0-9_-]+\/)*[a-z0-9_-]+\/([a-z_]+\.\w+)[:0-9]+/gmi15const deferred = () => {16 let reject17 let resolve18 const promise = new Promise((_resolve, _reject) => {19 resolve = _resolve20 reject = _reject21 })22 return { promise, resolve, reject }23}24const withoutColorCodes = (str) => {25 return str.replace(colorCodeRe, '<color-code>')26}27const withoutPath = (str) => {28 return str.replace(pathRe, '<path>$2)')29}30describe('lib/plugins/child/run_plugins', () => {31 beforeEach(function () {32 runPlugins.__reset()33 this.ipc = {34 send: sinon.spy(),35 on: sinon.stub(),36 removeListener: sinon.spy(),37 }38 })39 afterEach(() => {40 mockery.deregisterMock('plugins-file')41 mockery.deregisterSubstitute('plugins-file')42 mockery.deregisterMock('@cypress/webpack-batteries-included-preprocessor')43 })44 it('sends error message if pluginsFile is missing', function () {45 mockery.registerSubstitute('plugins-file', '/does/not/exist.coffee')46 runPlugins(this.ipc, 'plugins-file', 'proj-root')47 expect(this.ipc.send).to.be.calledWith('load:error', 'PLUGINS_FILE_ERROR', 'plugins-file')48 return snapshot(this.ipc.send.lastCall.args[3].split('\n')[0])49 })50 it('sends error message if requiring pluginsFile errors', function () {51 // path for substitute is relative to lib/plugins/child/plugins_child.js52 mockery.registerSubstitute(53 'plugins-file',54 Fixtures.path('server/throws_error.js'),55 )56 runPlugins(this.ipc, 'plugins-file', 'proj-root')57 expect(this.ipc.send).to.be.calledWith('load:error', 'PLUGINS_FILE_ERROR', 'plugins-file')58 return snapshot(this.ipc.send.lastCall.args[3].split('\n')[0])59 })60 it('sends error message if pluginsFile has syntax error', function () {61 // path for substitute is relative to lib/plugins/child/plugins_child.js62 mockery.registerSubstitute(63 'plugins-file',64 Fixtures.path('server/syntax_error.js'),65 )66 runPlugins(this.ipc, 'plugins-file', 'proj-root')67 expect(this.ipc.send).to.be.calledWith('load:error', 'PLUGINS_FILE_ERROR', 'plugins-file')68 return snapshot(withoutColorCodes(withoutPath(this.ipc.send.lastCall.args[3].replace(/( +at[^$]+$)+/g, '[stack trace]'))))69 })70 it('sends error message if pluginsFile does not export a function', function () {71 mockery.registerMock('plugins-file', null)72 runPlugins(this.ipc, 'plugins-file', 'proj-root')73 expect(this.ipc.send).to.be.calledWith('load:error', 'PLUGINS_DIDNT_EXPORT_FUNCTION', 'plugins-file')74 return snapshot(JSON.stringify(this.ipc.send.lastCall.args[3]))75 })76 describe('typescript registration', () => {77 beforeEach(() => {78 sinon.stub(tsNodeUtil, 'register')79 sinon.stub(resolve, 'typescript').returns('/path/to/typescript.js')80 })81 it('registers ts-node', function () {82 runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')83 expect(tsNodeUtil.register).to.be.calledWith(84 'proj-root',85 '/path/to/plugins/file.js',86 )87 })88 it('only registers ts-node once', function () {89 runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')90 runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')91 expect(tsNodeUtil.register).to.be.calledOnce92 })93 })94 describe('on \'load\' message', () => {95 it('sends loaded event with registrations', function () {96 const pluginsDeferred = deferred()97 const config = { projectRoot: '/project/root' }98 mockery.registerMock('plugins-file', (on) => {99 on('after:screenshot', () => {})100 on('task', {})101 return config102 })103 runPlugins(this.ipc, 'plugins-file', 'proj-root')104 this.ipc.on.withArgs('load').yield(config)105 pluginsDeferred.resolve(config)106 return Promise107 .delay(10)108 .then(() => {109 expect(this.ipc.send).to.be.calledWith('loaded', config)110 const registrations = this.ipc.send.lastCall.args[2]111 expect(registrations).to.have.length(5)112 expect(_.map(registrations, 'event')).to.eql([113 '_get:task:body',114 '_get:task:keys',115 'after:screenshot',116 'task',117 'file:preprocessor',118 ])119 })120 })121 it('registers default preprocessor if none registered by user', function () {122 const pluginsDeferred = deferred()123 const config = { projectRoot: '/project/root' }124 const webpackPreprocessorFn = sinon.spy()125 const webpackPreprocessor = sinon.stub().returns(webpackPreprocessorFn)126 sinon.stub(resolve, 'typescript').returns('/path/to/typescript.js')127 mockery.registerMock('plugins-file', (on) => {128 on('after:screenshot', () => {})129 on('task', {})130 return config131 })132 mockery.registerMock('@cypress/webpack-batteries-included-preprocessor', webpackPreprocessor)133 runPlugins(this.ipc, 'plugins-file', 'proj-root')134 this.ipc.on.withArgs('load').yield(config)135 pluginsDeferred.resolve(config)136 return Promise137 .delay(10)138 .then(() => {139 const registrations = this.ipc.send.lastCall.args[2]140 expect(webpackPreprocessor).to.be.calledWith({141 typescript: '/path/to/typescript.js',142 })143 expect(registrations[4]).to.eql({144 event: 'file:preprocessor',145 eventId: 4,146 })147 this.ipc.on.withArgs('execute').yield('file:preprocessor', { eventId: 4, invocationId: '00' }, ['arg1', 'arg2'])148 expect(webpackPreprocessorFn, 'webpackPreprocessor').to.be.called149 })150 })151 it('does not register default preprocessor if registered by user', function () {152 const pluginsDeferred = deferred()153 const config = { projectRoot: '/project/root' }154 const userPreprocessorFn = sinon.spy()155 const webpackPreprocessor = sinon.spy()156 sinon.stub(resolve, 'typescript').returns('/path/to/typescript.js')157 mockery.registerMock('plugins-file', (on) => {158 on('after:screenshot', () => {})159 on('file:preprocessor', userPreprocessorFn)160 on('task', {})161 return config162 })163 mockery.registerMock('@cypress/webpack-batteries-included-preprocessor', webpackPreprocessor)164 runPlugins(this.ipc, 'plugins-file', 'proj-root')165 this.ipc.on.withArgs('load').yield(config)166 pluginsDeferred.resolve(config)167 return Promise168 .delay(10)169 .then(() => {170 const registrations = this.ipc.send.lastCall.args[2]171 expect(webpackPreprocessor).not.to.be.called172 expect(registrations[3]).to.eql({173 event: 'file:preprocessor',174 eventId: 3,175 })176 this.ipc.on.withArgs('execute').yield('file:preprocessor', { eventId: 3, invocationId: '00' }, ['arg1', 'arg2'])177 expect(userPreprocessorFn).to.be.called178 })179 })180 it('sends error if pluginsFile function rejects the promise', function (done) {181 const err = new Error('foo')182 const pluginsFn = sinon.stub().rejects(err)183 mockery.registerMock('plugins-file', pluginsFn)184 this.ipc.on.withArgs('load').yields({})185 runPlugins(this.ipc, 'plugins-file', 'proj-root')186 this.ipc.send = _.once((event, errorType, pluginsFile, stack) => {187 expect(event).to.eq('load:error')188 expect(errorType).to.eq('PLUGINS_FUNCTION_ERROR')189 expect(pluginsFile).to.eq('plugins-file')190 expect(stack).to.eq(err.stack)191 return done()192 })193 })194 it('calls function exported by pluginsFile with register function and config', function () {195 const pluginsFn = sinon.spy()196 mockery.registerMock('plugins-file', pluginsFn)197 runPlugins(this.ipc, 'plugins-file', 'proj-root')198 const config = {}199 this.ipc.on.withArgs('load').yield(config)200 expect(pluginsFn).to.be.called201 expect(pluginsFn.lastCall.args[0]).to.be.a('function')202 expect(pluginsFn.lastCall.args[1]).to.equal(config)203 })204 it('sends error if pluginsFile function throws an error', function (done) {205 const err = new Error('foo')206 mockery.registerMock('plugins-file', () => {207 throw err208 })209 runPlugins(this.ipc, 'plugins-file', 'proj-root')210 this.ipc.on.withArgs('load').yield({})211 this.ipc.send = _.once((event, errorType, pluginsFile, stack) => {212 expect(event).to.eq('load:error')213 expect(errorType).to.eq('PLUGINS_FUNCTION_ERROR')214 expect(pluginsFile).to.eq('plugins-file')215 expect(stack).to.eq(err.stack)216 return done()217 })218 })219 })220 describe('on \'execute\' message', () => {221 beforeEach(function () {222 sinon.stub(preprocessor, 'wrap')223 this.onFilePreprocessor = sinon.stub().resolves()224 this.beforeBrowserLaunch = sinon.stub().resolves()225 this.taskRequested = sinon.stub().resolves('foo')226 const pluginsFn = (register) => {227 register('file:preprocessor', this.onFilePreprocessor)228 register('before:browser:launch', this.beforeBrowserLaunch)229 return register('task', this.taskRequested)230 }231 mockery.registerMock('plugins-file', pluginsFn)232 runPlugins(this.ipc, 'plugins-file', 'proj-root')233 return this.ipc.on.withArgs('load').yield({})234 })235 context('file:preprocessor', () => {236 beforeEach(function () {237 this.ids = { eventId: 0, invocationId: '00' }238 })239 it('calls preprocessor handler', function () {240 const args = ['arg1', 'arg2']241 this.ipc.on.withArgs('execute').yield('file:preprocessor', this.ids, args)242 expect(preprocessor.wrap).to.be.called243 expect(preprocessor.wrap.lastCall.args[0]).to.equal(this.ipc)244 expect(preprocessor.wrap.lastCall.args[1]).to.be.a('function')245 expect(preprocessor.wrap.lastCall.args[2]).to.equal(this.ids)246 expect(preprocessor.wrap.lastCall.args[3]).to.equal(args)247 })248 it('invokes registered function when invoked by handler', function () {249 this.ipc.on.withArgs('execute').yield('file:preprocessor', this.ids, [])250 preprocessor.wrap.lastCall.args[1](2, ['one', 'two'])251 expect(this.onFilePreprocessor).to.be.calledWith('one', 'two')252 })253 })254 context('before:browser:launch', () => {255 beforeEach(function () {256 sinon.stub(util, 'wrapChildPromise')257 const browser = {}258 const launchOptions = browserUtils.getDefaultLaunchOptions({})259 this.args = [browser, launchOptions]260 this.ids = { eventId: 1, invocationId: '00' }261 })262 it('wraps child promise', function () {263 this.ipc.on.withArgs('execute').yield('before:browser:launch', this.ids, this.args)264 expect(util.wrapChildPromise).to.be.called265 expect(util.wrapChildPromise.lastCall.args[0]).to.equal(this.ipc)266 expect(util.wrapChildPromise.lastCall.args[1]).to.be.a('function')267 expect(util.wrapChildPromise.lastCall.args[2]).to.equal(this.ids)268 expect(util.wrapChildPromise.lastCall.args[3]).to.equal(this.args)269 })270 it('invokes registered function when invoked by handler', function () {271 this.ipc.on.withArgs('execute').yield('before:browser:launch', this.ids, this.args)272 util.wrapChildPromise.lastCall.args[1](3, this.args)273 expect(this.beforeBrowserLaunch).to.be.calledWith(...this.args)274 })275 })276 context('task', () => {277 beforeEach(function () {278 sinon.stub(task, 'wrap')279 this.ids = { eventId: 5, invocationId: '00' }280 })281 it('calls task handler', function () {282 const args = ['arg1']283 this.ipc.on.withArgs('execute').yield('task', this.ids, args)284 expect(task.wrap).to.be.called285 expect(task.wrap.lastCall.args[0]).to.equal(this.ipc)286 expect(task.wrap.lastCall.args[1]).to.be.an('object')287 expect(task.wrap.lastCall.args[2]).to.equal(this.ids)288 expect(task.wrap.lastCall.args[3]).to.equal(args)289 })290 })291 })292 describe('errors', () => {293 beforeEach(function () {294 mockery.registerMock('plugins-file', () => {})295 sinon.stub(process, 'on')296 this.err = {297 name: 'error name',298 message: 'error message',299 }300 return runPlugins(this.ipc, 'plugins-file', 'proj-root')301 })302 it('sends the serialized error via ipc on process uncaughtException', function () {303 process.on.withArgs('uncaughtException').yield(this.err)304 expect(this.ipc.send).to.be.calledWith('error', this.err)305 })306 it('sends the serialized error via ipc on process unhandledRejection', function () {307 process.on.withArgs('unhandledRejection').yield(this.err)308 expect(this.ipc.send).to.be.calledWith('error', this.err)309 })310 it('sends the serialized reason via ipc on process unhandledRejection', function () {311 process.on.withArgs('unhandledRejection').yield({ reason: this.err })312 expect(this.ipc.send).to.be.calledWith('error', this.err)313 })314 })...

Full Screen

Full Screen

preprocessor.spec.js

Source:preprocessor.spec.js Github

copy

Full Screen

1'use strict'2const mocks = require('mocks')3const di = require('di')4const path = require('path')5const events = require('../../lib/events')6describe('preprocessor', () => {7 let pp8 let m9 let mockFs10 let emitterSetting11 // mimic first few bytes of a pdf file12 const binarydata = new Buffer([0x25, 0x50, 0x44, 0x66, 0x46, 0x00]) // eslint-disable-line node/no-deprecated-api13 beforeEach(() => {14 mockFs = mocks.fs.create({15 some: {16 'a.js': mocks.fs.file(0, 'content'),17 'b.js': mocks.fs.file(0, 'content'),18 'a.txt': mocks.fs.file(0, 'some-text'),19 'photo.png': mocks.fs.file(0, binarydata),20 'CAM_PHOTO.JPG': mocks.fs.file(0, binarydata),21 '.dir': {22 'a.js': mocks.fs.file(0, 'content')23 }24 }25 })26 const mocks_ = {27 'graceful-fs': mockFs,28 minimatch: require('minimatch')29 }30 emitterSetting = {'emitter': ['value', new events.EventEmitter()]}31 m = mocks.loadFile(path.join(__dirname, '/../../lib/preprocessor.js'), mocks_)32 })33 it('should preprocess matching file', (done) => {34 const fakePreprocessor = sinon.spy((content, file, done) => {35 file.path = file.path + '-preprocessed'36 done(null, 'new-content')37 })38 const injector = new di.Injector([{39 'preprocessor:fake': [40 'factory', function () { return fakePreprocessor }41 ]42 }, emitterSetting])43 pp = m.createPreprocessor({'**/*.js': ['fake']}, null, injector)44 const file = {originalPath: '/some/a.js', path: 'path'}45 pp(file, () => {46 expect(fakePreprocessor).to.have.been.called47 expect(file.path).to.equal('path-preprocessed')48 expect(file.content).to.equal('new-content')49 done()50 })51 })52 it('should match directories starting with a dot', (done) => {53 const fakePreprocessor = sinon.spy((content, file, done) => {54 file.path = file.path + '-preprocessed'55 done(null, 'new-content')56 })57 const injector = new di.Injector([{58 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]59 }, emitterSetting])60 pp = m.createPreprocessor({'**/*.js': ['fake']}, null, injector)61 const file = {originalPath: '/some/.dir/a.js', path: 'path'}62 pp(file, () => {63 expect(fakePreprocessor).to.have.been.called64 expect(file.path).to.equal('path-preprocessed')65 expect(file.content).to.equal('new-content')66 done()67 })68 })69 it('should check patterns after creation when invoked', (done) => {70 const fakePreprocessor = sinon.spy((content, file, done) => {71 file.path = file.path + '-preprocessed'72 done(null, 'new-content')73 })74 const injector = new di.Injector([{75 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]76 }, emitterSetting])77 const config = {'**/*.txt': ['fake']}78 pp = m.createPreprocessor(config, null, injector)79 const file = {originalPath: '/some/a.js', path: 'path'}80 config['**/*.js'] = ['fake']81 pp(file, () => {82 expect(fakePreprocessor).to.have.been.called83 expect(file.path).to.equal('path-preprocessed')84 expect(file.content).to.equal('new-content')85 done()86 })87 })88 it('should ignore not matching file', (done) => {89 const fakePreprocessor = sinon.spy((content, file, done) => {90 done(null, '')91 })92 const injector = new di.Injector([{93 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]94 }, emitterSetting])95 pp = m.createPreprocessor({'**/*.js': ['fake']}, null, injector)96 const file = {originalPath: '/some/a.txt', path: 'path'}97 pp(file, () => {98 expect(fakePreprocessor).to.not.have.been.called99 done()100 })101 })102 it('should apply all preprocessors', (done) => {103 const fakePreprocessor1 = sinon.spy((content, file, done) => {104 file.path = file.path + '-p1'105 done(null, content + '-c1')106 })107 const fakePreprocessor2 = sinon.spy((content, file, done) => {108 file.path = file.path + '-p2'109 done(content + '-c2')110 })111 const injector = new di.Injector([{112 'preprocessor:fake1': ['factory', function () { return fakePreprocessor1 }],113 'preprocessor:fake2': ['factory', function () { return fakePreprocessor2 }]114 }, emitterSetting])115 pp = m.createPreprocessor({'**/*.js': ['fake1', 'fake2']}, null, injector)116 const file = {originalPath: '/some/a.js', path: 'path'}117 pp(file, () => {118 expect(fakePreprocessor1).to.have.been.calledOnce119 expect(fakePreprocessor2).to.have.been.calledOnce120 expect(file.path).to.equal('path-p1-p2')121 expect(file.content).to.equal('content-c1-c2')122 done()123 })124 })125 it('should compute SHA', (done) => {126 pp = m.createPreprocessor({}, null, new di.Injector([emitterSetting]))127 const file = {originalPath: '/some/a.js', path: 'path'}128 pp(file, () => {129 expect(file.sha).to.exist130 expect(file.sha.length).to.equal(40)131 const previousSHA = file.sha132 pp(file, () => {133 expect(file.sha).to.equal(previousSHA)134 mockFs._touchFile('/some/a.js', null, 'new-content')135 pp(file, () => {136 expect(file.sha.length).to.equal(40)137 expect(file.sha).not.to.equal(previousSHA)138 done()139 })140 })141 })142 })143 it('should compute SHA from content returned by a processor', (done) => {144 const fakePreprocessor = sinon.spy((content, file, done) => {145 done(null, content + '-processed')146 })147 const injector = new di.Injector([{148 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]149 }, emitterSetting])150 pp = m.createPreprocessor({'**/a.js': ['fake']}, null, injector)151 const fileProcess = {originalPath: '/some/a.js', path: 'path'}152 const fileSkip = {originalPath: '/some/b.js', path: 'path'}153 pp(fileProcess, () => {154 pp(fileSkip, () => {155 expect(fileProcess.sha).to.exist156 expect(fileProcess.sha.length).to.equal(40)157 expect(fileSkip.sha).to.exist158 expect(fileSkip.sha.length).to.equal(40)159 expect(fileProcess.sha).not.to.equal(fileSkip.sha)160 done()161 })162 })163 })164 it('should return error if any preprocessor fails', (done) => {165 const failingPreprocessor = sinon.spy((content, file, done) => {166 done(new Error('Some error'), null)167 })168 const injector = new di.Injector([{169 'preprocessor:failing': ['factory', function () { return failingPreprocessor }]170 }, emitterSetting])171 pp = m.createPreprocessor({'**/*.js': ['failing']}, null, injector)172 const file = {originalPath: '/some/a.js', path: 'path'}173 pp(file, (err) => {174 expect(err).to.exist175 done()176 })177 })178 it('should stop preprocessing after an error', (done) => {179 const failingPreprocessor = sinon.spy((content, file, done) => {180 done(new Error('Some error'), null)181 })182 const fakePreprocessor = sinon.spy((content, file, done) => {183 done(null, content)184 })185 const injector = new di.Injector([{186 'preprocessor:failing': ['factory', function () { return failingPreprocessor }],187 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]188 }, emitterSetting])189 pp = m.createPreprocessor({'**/*.js': ['failing', 'fake']}, null, injector)190 const file = {originalPath: '/some/a.js', path: 'path'}191 pp(file, () => {192 expect(fakePreprocessor).not.to.have.been.called193 done()194 })195 })196 describe('when fs.readFile fails', () => {197 const file = {originalPath: '/some/a.js', path: 'path'}198 const getReadFileCallback = (nthCall) => {199 return mockFs.readFile.args[nthCall][1]200 }201 beforeEach(() => {202 sinon.stub(mockFs, 'readFile')203 })204 it('should retry up to 3 times', (done) => {205 const fakePreprocessor = sinon.spy((content, file, done) => {206 done(null, content)207 })208 const injector = new di.Injector([{209 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]210 }, emitterSetting])211 const pp = m.createPreprocessor({'**/*.js': ['fake']}, null, injector)212 pp(file, () => {213 expect(fakePreprocessor).to.have.been.called214 done()215 })216 getReadFileCallback(0)('error')217 getReadFileCallback(1)('error')218 const thirdCallback = getReadFileCallback(2)219 mockFs.readFile.restore()220 thirdCallback('error')221 })222 it('should throw after 3 retries', (done) => {223 const injector = new di.Injector([{}, emitterSetting])224 const pp = m.createPreprocessor({'**/*.js': []}, null, injector)225 pp(file, () => { })226 getReadFileCallback(0)('error')227 getReadFileCallback(1)('error')228 getReadFileCallback(2)('error')229 expect(() => getReadFileCallback(0)('error')).to.throw('error')230 done()231 })232 })233 it('should not preprocess binary files by default', (done) => {234 const fakePreprocessor = sinon.spy((content, file, done) => {235 done(null, content)236 })237 const injector = new di.Injector([{238 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]239 }, emitterSetting])240 pp = m.createPreprocessor({'**/*': ['fake']}, null, injector)241 const file = {originalPath: '/some/photo.png', path: 'path'}242 pp(file, (err) => {243 if (err) throw err244 expect(fakePreprocessor).not.to.have.been.called245 expect(file.content).to.be.an.instanceof(Buffer)246 done()247 })248 })249 it('should preprocess binary files if handleBinaryFiles=true', (done) => {250 const fakePreprocessor = sinon.spy((content, file, done) => {251 done(null, content)252 })253 fakePreprocessor.handleBinaryFiles = true254 const injector = new di.Injector([{255 'preprocessor:fake': ['factory', function () { return fakePreprocessor }]256 }, emitterSetting])257 pp = m.createPreprocessor({'**/*': ['fake']}, null, injector)258 const file = {originalPath: '/some/photo.png', path: 'path'}259 pp(file, (err) => {260 if (err) throw err261 expect(fakePreprocessor).to.have.been.calledOnce262 expect(file.content).to.be.an.instanceof(Buffer)263 done()264 })265 })266 it('should not preprocess binary files with capital letters in extension', (done) => {267 const fakePreprocessor = sinon.spy((content, file, done) => {268 done(null, content)269 })270 const injector = new di.Injector([{271 'preprocessor:fake': ['factory', function () { fakePreprocessor }]272 }, emitterSetting])273 pp = m.createPreprocessor({'**/*': ['fake']}, null, injector)274 const file = {originalPath: '/some/CAM_PHOTO.JPG', path: 'path'}275 pp(file, (err) => {276 if (err) throw err277 expect(fakePreprocessor).not.to.have.been.called278 expect(file.content).to.be.an.instanceof(Buffer)279 done()280 })281 })282 it('should merge lists of preprocessors', (done) => {283 const callOrder = []284 const fakePreprocessorA = sinon.spy((content, file, done) => {285 callOrder.push('a')286 done(null, content)287 })288 const fakePreprocessorB = sinon.spy((content, file, done) => {289 callOrder.push('b')290 done(null, content)291 })292 const fakePreprocessorC = sinon.spy((content, file, done) => {293 callOrder.push('c')294 done(null, content)295 })296 const fakePreprocessorD = sinon.spy((content, file, done) => {297 callOrder.push('d')298 done(null, content)299 })300 const injector = new di.Injector([{301 'preprocessor:fakeA': ['factory', function () { return fakePreprocessorA }],302 'preprocessor:fakeB': ['factory', function () { return fakePreprocessorB }],303 'preprocessor:fakeC': ['factory', function () { return fakePreprocessorC }],304 'preprocessor:fakeD': ['factory', function () { return fakePreprocessorD }]305 }, emitterSetting])306 pp = m.createPreprocessor({307 '/*/a.js': ['fakeA', 'fakeB'],308 '/some/*': ['fakeB', 'fakeC'],309 '/some/a.js': ['fakeD']310 }, null, injector)311 const file = {originalPath: '/some/a.js', path: 'path'}312 pp(file, (err) => {313 if (err) throw err314 expect(fakePreprocessorA).to.have.been.called315 expect(fakePreprocessorB).to.have.been.called316 expect(fakePreprocessorC).to.have.been.called317 expect(fakePreprocessorD).to.have.been.called318 expect(callOrder.indexOf('d')).not.to.equal(-1)319 expect(callOrder.filter((letter) => {320 return letter !== 'd'321 })).to.eql(['a', 'b', 'c'])322 done()323 })324 })...

Full Screen

Full Screen

preprocessor_spec.js

Source:preprocessor_spec.js Github

copy

Full Screen

1require('../../spec_helper')2const Fixtures = require('../../support/helpers/fixtures')3const path = require('path')4const appData = require(`${root}../lib/util/app_data`)5const plugins = require(`${root}../lib/plugins`)6const preprocessor = require(`${root}../lib/plugins/preprocessor`)7describe('lib/plugins/preprocessor', () => {8 beforeEach(function () {9 Fixtures.scaffold()10 this.todosPath = Fixtures.projectPath('todos')11 this.filePath = 'path/to/test.coffee'12 this.fullFilePath = path.join(this.todosPath, this.filePath)13 this.integrationFolder = '/integration-path/'14 this.testPath = path.join(this.todosPath, 'test.coffee')15 this.localPreprocessorPath = path.join(this.todosPath, 'prep.coffee')16 this.plugin = sinon.stub().returns('/path/to/output.js')17 plugins.register('file:preprocessor', this.plugin)18 preprocessor.close()19 this.config = {20 preprocessor: 'custom',21 projectRoot: this.todosPath,22 }23 })24 context('#getFile', () => {25 it('executes the plugin with file path', function () {26 preprocessor.getFile(this.filePath, this.config)27 expect(this.plugin).to.be.called28 expect(this.plugin.lastCall.args[0].filePath).to.equal(this.fullFilePath)29 })30 it('executes the plugin with output path', function () {31 preprocessor.getFile(this.filePath, this.config)32 const expectedPath = appData.projectsPath(appData.toHashName(this.todosPath), 'bundles', this.filePath)33 expect(this.plugin.lastCall.args[0].outputPath).to.equal(expectedPath)34 })35 it('executes the plugin with output path when integrationFolder was defined', function () {36 preprocessor.getFile(this.integrationFolder + this.filePath, Object.assign({ integrationFolder: this.integrationFolder }, this.config))37 const expectedPath = appData.projectsPath(appData.toHashName(this.todosPath), 'bundles', this.filePath)38 expect(this.plugin.lastCall.args[0].outputPath).to.equal(expectedPath)39 })40 it('returns a promise resolved with the plugin\'s outputPath', function () {41 return preprocessor.getFile(this.filePath, this.config).then((filePath) => {42 expect(filePath).to.equal('/path/to/output.js')43 })44 })45 it('emits \'file:updated\' with filePath when \'rerun\' is emitted', function () {46 const fileUpdated = sinon.spy()47 preprocessor.emitter.on('file:updated', fileUpdated)48 preprocessor.getFile(this.filePath, this.config)49 this.plugin.lastCall.args[0].emit('rerun')50 expect(fileUpdated).to.be.calledWith(this.fullFilePath)51 })52 it('invokes plugin again when isTextTerminal: false', function () {53 this.config.isTextTerminal = false54 preprocessor.getFile(this.filePath, this.config)55 preprocessor.getFile(this.filePath, this.config)56 expect(this.plugin).to.be.calledTwice57 })58 it('does not invoke plugin again when isTextTerminal: true', function () {59 this.config.isTextTerminal = true60 preprocessor.getFile(this.filePath, this.config)61 preprocessor.getFile(this.filePath, this.config)62 expect(this.plugin).to.be.calledOnce63 })64 })65 context('#removeFile', () => {66 it('emits \'close\'', function () {67 preprocessor.getFile(this.filePath, this.config)68 const onClose = sinon.spy()69 this.plugin.lastCall.args[0].on('close', onClose)70 preprocessor.removeFile(this.filePath, this.config)71 expect(onClose).to.be.called72 })73 it('emits \'close\' with file path on base emitter', function () {74 const onClose = sinon.spy()75 preprocessor.emitter.on('close', onClose)76 preprocessor.getFile(this.filePath, this.config)77 preprocessor.removeFile(this.filePath, this.config)78 expect(onClose).to.be.calledWith(this.fullFilePath)79 })80 })81 context('#close', () => {82 it('emits \'close\' on config emitter', function () {83 preprocessor.getFile(this.filePath, this.config)84 const onClose = sinon.spy()85 this.plugin.lastCall.args[0].on('close', onClose)86 preprocessor.close()87 expect(onClose).to.be.called88 })89 it('emits \'close\' on base emitter', function () {90 const onClose = sinon.spy()91 preprocessor.emitter.on('close', onClose)92 preprocessor.getFile(this.filePath, this.config)93 preprocessor.close()94 expect(onClose).to.be.called95 })96 })97 context('#clientSideError', () => {98 beforeEach(() => {99 return sinon.stub(console, 'error')100 }) // keep noise out of console101 it('send javascript string with the error', () => {102 expect(preprocessor.clientSideError('an error')).to.equal(`\103(function () {104 Cypress.action("spec:script:error", {105 type: "BUNDLE_ERROR",106 error: "an error"107 })108}())\109`)110 })111 it('does not replace new lines with {newline} placeholder', () => {112 expect(preprocessor.clientSideError('with\nnew\nlines')).to.include('error: "with\\nnew\\nlines"')113 })114 it('does not remove command line syntax highlighting characters', () => {115 expect(preprocessor.clientSideError('[30mfoo[100mbar[7mbaz')).to.include('error: "[30mfoo[100mbar[7mbaz"')116 })117 })118 context('#errorMessage', () => {119 it('handles error strings', () => {120 expect(preprocessor.errorMessage('error string')).to.include('error string')121 })122 it('handles standard error objects and sends the stack', () => {123 const err = new Error()124 err.stack = 'error object stack'125 expect(preprocessor.errorMessage(err)).to.equal('error object stack')126 })127 it('sends err.annotated if stack is not present', () => {128 const err = {129 stack: undefined,130 annotated: 'annotation',131 }132 expect(preprocessor.errorMessage(err)).to.equal('annotation')133 })134 it('sends err.message if stack and annotated are not present', () => {135 const err = {136 stack: undefined,137 message: 'message',138 }139 expect(preprocessor.errorMessage(err)).to.equal('message')140 })141 it('does not remove stack lines', () => {142 expect(preprocessor.errorMessage('foo\n at what.ever (foo 23:30)\n baz\n at where.ever (bar 1:5)'))143 .to.equal('foo\n at what.ever (foo 23:30)\n baz\n at where.ever (bar 1:5)')144 })145 })...

Full Screen

Full Screen

preprocessor.js

Source:preprocessor.js Github

copy

Full Screen

1'use strict'2const fs = require('graceful-fs')3const mm = require('minimatch')4const isBinaryFile = require('isbinaryfile')5const combineLists = require('combine-lists')6const CryptoUtils = require('./utils/crypto-utils')7const log = require('./logger').create('preprocess')8function createNextProcessor (preprocessors, file, done) {9 return function nextPreprocessor (error, content) {10 // normalize B-C11 if (arguments.length === 1 && typeof error === 'string') {12 content = error13 error = null14 }15 if (error) {16 file.content = null17 file.contentPath = null18 return done(error)19 }20 if (!preprocessors.length) {21 file.contentPath = null22 file.content = content23 file.sha = CryptoUtils.sha1(content)24 return done()25 }26 preprocessors.shift()(content, file, nextPreprocessor)27 }28}29function createPreprocessor (config, basePath, injector) {30 const emitter = injector.get('emitter')31 const alreadyDisplayedErrors = {}32 const instances = {}33 let patterns = Object.keys(config)34 function instantiatePreprocessor (name) {35 if (alreadyDisplayedErrors[name]) {36 return37 }38 let p39 try {40 p = injector.get('preprocessor:' + name)41 } catch (e) {42 if (e.message.includes(`No provider for "preprocessor:${name}"`)) {43 log.error(`Can not load "${name}", it is not registered!\n Perhaps you are missing some plugin?`)44 } else {45 log.error(`Can not load "${name}"!\n ` + e.stack)46 }47 alreadyDisplayedErrors[name] = true48 emitter.emit('load_error', 'preprocessor', name)49 }50 return p51 }52 let allPreprocessors = []53 patterns.forEach((pattern) => {54 allPreprocessors = combineLists(allPreprocessors, config[pattern])55 })56 allPreprocessors.forEach(instantiatePreprocessor)57 return function preprocess (file, done) {58 patterns = Object.keys(config)59 let retryCount = 060 let maxRetries = 361 function readFileCallback (err, buffer) {62 if (err) {63 log.warn(err)64 if (retryCount < maxRetries) {65 retryCount++66 log.warn('retrying ' + retryCount)67 fs.readFile(file.originalPath, readFileCallback)68 return69 } else {70 throw err71 }72 }73 isBinaryFile(buffer, buffer.length, function (err, isBinary) {74 if (err) {75 throw err76 }77 let preprocessorNames = []78 patterns.forEach((pattern) => {79 if (mm(file.originalPath, pattern, {dot: true})) {80 preprocessorNames = combineLists(preprocessorNames, config[pattern])81 }82 })83 let preprocessors = []84 const nextPreprocessor = createNextProcessor(preprocessors, file, done)85 preprocessorNames.forEach((name) => {86 const p = instances[name] || instantiatePreprocessor(name)87 if (p == null) {88 if (!alreadyDisplayedErrors[name]) {89 alreadyDisplayedErrors[name] = true90 log.error(`Failed to instantiate preprocessor ${name}`)91 emitter.emit('load_error', 'preprocessor', name)92 }93 return94 }95 instances[name] = p96 if (!isBinary || p.handleBinaryFiles) {97 preprocessors.push(p)98 } else {99 log.warn(`Ignored preprocessing ${file.originalPath} because ${name} has handleBinaryFiles=false.`)100 }101 })102 nextPreprocessor(null, isBinary ? buffer : buffer.toString())103 })104 }105 return fs.readFile(file.originalPath, readFileCallback)106 }107}108createPreprocessor.$inject = ['config.preprocessors', 'config.basePath', 'injector']...

Full Screen

Full Screen

PreprocessorSpec.js

Source:PreprocessorSpec.js Github

copy

Full Screen

1describe("Command.Preprocessor", function() {2 var preprocessor = Ext.create('Command.Preprocessor');3 beforeEach(function() {4 preprocessor.setParams({5 browser: 'ie',6 browserVersion: 6,7 version: 3.1,8 minVersion: 2.0,9 debug: true10 });11 });12 describe("evaluate()", function() {13 it("Browser is IE", function() {14 expect(preprocessor.evaluate('browser', 'ie')).toBe(true);15 });16 it("Browser is not firefox", function() {17 expect(preprocessor.evaluate('browser', '!firefox')).toBe(true);18 });19 it("Browser version is greater than 5", function() {20 expect(preprocessor.evaluate('browserVersion', '>5')).toBe(true);21 });22 it("Browser version is less than 7", function() {23 expect(preprocessor.evaluate('browserVersion', '<7')).toBe(true);24 });25 it("Browser version is greater or equal to 6", function() {26 expect(preprocessor.evaluate('browserVersion', '>=6')).toBe(true);27 });28 it("Nonexistent", function() {29 expect(preprocessor.evaluate('nonexistent')).toBe(false);30 });31 });32 describe("isStatement()", function() {33 it("//<if browser=ie> is a valid statement", function() {34 expect(preprocessor.isStatement('//<if browser=ie>')).toBe(true);35 });36 it(" //<if browser=ie> (tab in front) is a valid statement", function() {37 expect(preprocessor.isStatement(' //<if browser=ie>')).toBe(true);38 });39 it("//<if browser=ie> (spaces at the end) is a valid statement", function() {40 expect(preprocessor.isStatement('//<if browser=ie> ')).toBe(true);41 });42 it("//</if> is not a valid opening statement", function() {43 expect(preprocessor.isStatement('//</if>')).toBe(false);44 });45 });46 describe("isCloseOf()", function() {47 it("//</if> is valid close of if", function() {48 expect(preprocessor.isCloseOf('//</if>', { type: 'if', isInverted: false })).toBe(true);49 });50 it("//</!if> is valid close of inverted if", function() {51 expect(preprocessor.isCloseOf('//</!if>', { type: 'if', isInverted: true })).toBe(true);52 });53 });54 describe("parseStatementProperties()", function() {55 it("'browser=ie debug' => { browser: 'ie', debug: true }", function() {56 expect(preprocessor.parseStatementProperties('browser=ie debug')).toEqual({ browser: 'ie', debug: true });57 });58 it("'browser=\"ie\" browserVersion='!7' debug=false' " +59 "=> { browser: 'ie', browserVersion: '!7', debug: \"false\" }", function() {60 expect(preprocessor.parseStatementProperties('browser="ie" browserVersion=\'!7\' debug=false')).toEqual({61 browser: 'ie',62 browserVersion: '!7',63 debug: "false"64 });65 });66 });67 describe("parseStatement()", function() {68 it("//<deprecated since=\"3.0\"> => { properties: { since: '3.0' }, type: 'deprecated', isInverted: false }", function() {69 expect(preprocessor.parseStatement('//<deprecated since="3.0">')).toEqual({70 properties: { since: '3.0' },71 type: 'deprecated',72 isInverted: false73 });74 });75 });...

Full Screen

Full Screen

css-editor.js

Source:css-editor.js Github

copy

Full Screen

1/* global postboxes, addLoadEvent */2( function( $ ) {3 var safe, win, safecssResize, safecssInit;4 safecssResize = function() {5 safe.height( win.height() - safe.offset().top - 250 );6 };7 safecssInit = function() {8 safe = $( '#safecss' );9 win = $( window );10 postboxes.add_postbox_toggles( 'editcss' );11 safecssResize();12 // Bound on a parent to ensure that this click event executes last.13 $( '#safecssform' ).on( 'click', '#preview', function( e ) {14 e.preventDefault();15 document.forms.safecssform.target = 'csspreview';16 document.forms.safecssform.action.value = 'preview';17 document.forms.safecssform.submit();18 document.forms.safecssform.target = '';19 document.forms.safecssform.action.value = 'save';20 } );21 };22 window.onresize = safecssResize;23 addLoadEvent( safecssInit );24} )( jQuery );25jQuery( function( $ ) {26 $( '.edit-preprocessor' ).bind( 'click', function( e ) {27 e.preventDefault();28 $( '#preprocessor-select' ).slideDown();29 $( this ).hide();30 } );31 $( '.cancel-preprocessor' ).bind( 'click', function( e ) {32 e.preventDefault();33 $( '#preprocessor-select' ).slideUp( function() {34 $( '.edit-preprocessor' ).show();35 $( '#preprocessor_choices' ).val( $( '#custom_css_preprocessor' ).val() );36 } );37 } );38 $( '.save-preprocessor' ).bind( 'click', function( e ) {39 e.preventDefault();40 $( '#preprocessor-select' ).slideUp();41 $( '#preprocessor-display' ).text( $( '#preprocessor_choices option:selected' ).text() );42 $( '#custom_css_preprocessor' )43 .val( $( '#preprocessor_choices' ).val() )44 .change();45 $( '.edit-preprocessor' ).show();46 } );47 $( '.edit-css-mode' ).bind( 'click', function( e ) {48 e.preventDefault();49 $( '#css-mode-select' ).slideDown();50 $( this ).hide();51 } );52 $( '.cancel-css-mode' ).bind( 'click', function( e ) {53 e.preventDefault();54 $( '#css-mode-select' ).slideUp( function() {55 $( '.edit-css-mode' ).show();56 $( 'input[name=add_to_existing_display][value=' + $( '#add_to_existing' ).val() + ']' ).attr(57 'checked',58 true59 );60 } );61 } );62 $( '.save-css-mode' ).bind( 'click', function( e ) {63 e.preventDefault();64 $( '#css-mode-select' ).slideUp();65 $( '#css-mode-display' ).text(66 $( 'input[name=add_to_existing_display]:checked' ).val() === 'true' ? 'Add-on' : 'Replacement'67 );68 $( '#add_to_existing' ).val( $( 'input[name=add_to_existing_display]:checked' ).val() );69 $( '.edit-css-mode' ).show();70 } );...

Full Screen

Full Screen

all_b.js

Source:all_b.js Github

copy

Full Screen

1var searchData=2[3 ['preprocessor_0',['Preprocessor',['../class_preprocessor.html',1,'']]],4 ['preprocessor_2ecpp_1',['Preprocessor.cpp',['../_preprocessor_8cpp.html',1,'']]],5 ['preprocessor_2eh_2',['Preprocessor.h',['../_preprocessor_8h.html',1,'']]],6 ['preprocessorexception_3',['PreprocessorException',['../class_preprocessor_1_1_preprocessor_exception.html',1,'Preprocessor::PreprocessorException'],['../class_preprocessor_1_1_preprocessor_exception.html#aaa87c134091e33dbf93540a87c2f75ba',1,'Preprocessor::PreprocessorException::PreprocessorException()']]],7 ['process_4',['Process',['../class_preprocessor.html#a45aef48fa68ab5eca2c29cf0d9b574d9',1,'Preprocessor']]],8 ['psw_5',['PSW',['../struct_p_s_w.html',1,'']]]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test Suite', function() 2{3it('My FirstTest case',function() {4cy.get('#checkBoxOption1').check().should('be.checked').and('have.value','option1')5cy.get('#checkBoxOption1').uncheck().should('not.be.checked')6cy.get('input[type="checkbox"]').check(['option2','option3'])7cy.get('select').select('option2').should('have.value','option2')8cy.get('#autocomplete').type('ind')9cy.get('.ui-menu-item div').each(($el, index, $list) => {10if($el.text()==="India")11{12$el.click()13}14})15cy.get('#autocomplete').should('have.value','India')16cy.get('#displayed-text').should('be.visible')17cy.get('#hide-textbox').click()18cy.get('#displayed-text').should('not.be.visible')19cy.get('#show-textbox').click()20cy.get('#displayed-text').should('be.visible')21cy.get('[value="radio2"]').check().should('be.checked')22cy.get('tr td:nth-child(2)').each(($el, index, $list) => {23const text=$el.text()24if(text.includes("Python"))25{26cy.get('tr td:nth-child(2)').eq(index).next().then(function(price)27{28const priceText=price.text()29expect(priceText).to.equal('25')30})31}32})33})34})35{

Full Screen

Using AI Code Generation

copy

Full Screen

1const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');2module.exports = (on, config) => {3 on('file:preprocessor', preprocessTypescript(config));4};5{6 "compilerOptions": {7 },8}9{10}11import { Given, Then } from 'cypress-cucumber-preprocessor/steps';12Given('I open the app', () => {13 cy.visit('/');14});15Then('I should see the title {string}', (title) => {16 cy.get('h1').should('contain', title);17});18import cucumber from 'cypress-cucumber-preprocessor';19module.exports = (on, config) => {20 on('file:preprocessor', cucumber());21};22import '@cypress/code-coverage/support';23import 'cypress-axe';24import 'cypress-iframe';25import 'cypress-wait-until';26import 'cypress-plugin-tab';27import 'cypress-localstorage-commands';28import 'cypress-file-upload';29import './commands';30import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';31declare namespace Cypress {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';2addMatchImageSnapshotCommand({3 customDiffConfig: {threshold: 0.0},4});5describe('Test', () => {6 it('should work', () => {7 cy.matchImageSnapshot('Google');8 });9});10at Object.throwErr [as throw] (Cypress\resources\app\packages\server\lib\errors.js:172:11)11at Object.throwErrByPath (Cypress\resources\app\packages\server\lib\errors.js:210:17)12at tryCatcher (C:\Users\runneradmin\AppData\Local\Cypress\Cache\6.4.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)13at Promise._settlePromiseFromHandler (C:\Users\runneradmin\AppData\Local\Cypress\Cache\6.4.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:547:31)14at Promise._settlePromise (C:\Users\runneradmin\AppData\Local\Cypress\Cache\6.4.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:604:18)15at Promise._settlePromise0 (C:\Users\runneradmin\AppData\Local\Cypress\Cache\6.4.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:649:10)16at Promise._settlePromises (C:\Users\

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5 })6 describe('My First Test', function() {7 it('Does not do much!', function() {8 expect(true).to.equal(false)9 })10 })11 describe('My First Test', function() {12 it('Does not do much!', function() {13 expect(true).to.equal(true)14 })15 })16 describe('My First Test', function() {17 it('Does not do much!', function() {18 expect(true).to.equal(false)19 })20 })21 describe('My First Test', function() {22 it('Does not do much!', function() {23 expect(true).to.equal(true)24 })25 })26 describe('My First Test', function() {27 it('Does not do much!', function() {28 expect(true).to.equal(false)29 })30 })31 describe('My First Test', function() {32 it('Does not do much!', function() {33 expect(true).to.equal(true)34 })35 })36 describe('My First Test', function() {37 it('Does not do much!', function() {38 expect(true).to.equal(false)39 })40 })41 describe('My First Test', function() {42 it('Does not do much!', function() {43 expect(true).to.equal(true)44 })45 })46 describe('My First Test', function() {47 it('Does not do much!', function() {48 expect(true).to.equal(false)49 })50 })51 describe('My First Test', function() {52 it('Does not do much!', function() {53 expect(true).to.equal(true)54 })55 })56 describe('My First Test', function() {57 it('Does not do much!', function() {58 expect(true).to.equal(false)59 })60 })61 describe('My First Test', function() {62 it('Does not do much!', function() {63 expect(true).to.equal(true)64 })65 })66 describe('My First Test', function() {67 it('Does not do much!', function() {68 expect(true).to.equal(false)69 })70 })71 describe('My First Test', function() {72 it('Does not do much!', function() {73 expect(true).to.equal(true)

Full Screen

Using AI Code Generation

copy

Full Screen

1import './commands'2import './page-objects'3import './data'4import './custom-commands'5Cypress.on('uncaught:exception', (err, runnable) => {6})7import './custom-commands'8Cypress.on('uncaught:exception', (err, runnable) => {9})10import './custom-commands'11Cypress.on('uncaught:exception', (err, runnable) => {12})13import './custom-commands'14Cypress.on('uncaught:exception', (err, runnable) => {15})16import './custom-commands'17Cypress.on('uncaught:exception', (err, runnable) => {18})19import './custom-commands'20Cypress.on('uncaught:exception', (err, runnable) => {21})22import './custom-commands'23Cypress.on('uncaught:exception', (err, runnable) => {24})25import './custom-commands'26Cypress.on('uncaught:exception', (err, runnable) => {27})28import './custom-commands'29Cypress.on('uncaught:exception', (err, runnable) => {30})31import './custom-commands'32Cypress.on('uncaught:exception', (err, runnable) => {33})34import './custom-commands'35Cypress.on('uncaught:exception', (err, runnable) => {36})37import './custom-commands'38Cypress.on('uncaught:exception', (err, runnable) => {39})40import './custom-commands'41Cypress.on('uncaught:exception', (err, runnable) => {42})43import './custom-commands'44Cypress.on('uncaught:exception', (err, runnable) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { readFileSync } = require("fs");2const { join } = require("path");3const json = readFileSync(join(__dirname, "..", "cypress", "fixtures", "example.json"));4const data = JSON.parse(json);5describe("My First Test", () => {6 it("Visits the Kitchen Sink", () => {7 cy.contains("type").click();8 cy.url().should("include", "/commands/actions");9 cy.get(".action-email")10 .type(data.email)11 .should("have.value", data.email);12 });13});14{

Full Screen

Using AI Code Generation

copy

Full Screen

1const { env } = require("process");2const envVariable = Cypress.env('variableName');3const envVariable = Cypress.env('variableName');4const envVariable = Cypress.env('variableName');5const envVariable = Cypress.env('variableName');6const envVariable = Cypress.env('variableName');7const envVariable = Cypress.env('variableName');8const envVariable = Cypress.env('variableName');9const envVariable = Cypress.env('variableName');10const envVariable = Cypress.env('variableName');11const envVariable = Cypress.env('variableName');12const envVariable = Cypress.env('variableName');13const envVariable = Cypress.env('variableName');14const envVariable = Cypress.env('variableName');

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test Suite', function() 2{3it('My FirstTest case',function() {4 cy.get('#name').type("Magesh")5 cy.get('#alertbtn').click()6 cy.get('[value="Confirm"]').click()7 cy.on('window:alert',(str)=>8 {9 expect(str).to.equal('Hello , share this practice page and share your knowledge')10 })11 cy.on('window:confirm',(str)=>12 {13 expect(str).to.equal('Hello , Are you sure you want to confirm?')14 })15 cy.get('#opentab').invoke('removeAttr','target').click()16 cy.url().should('include','rahulshettyacademy')17 cy.go('back')18})19})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful