How to use isNewPlugin method in Jest

Best JavaScript code snippet using jest

index.js

Source:index.js Github

copy

Full Screen

...247 printer248 ) +249 '}';250}251function isNewPlugin(plugin) {252 return plugin.serialize != null;253}254function printPlugin(plugin, val, config, indentation, depth, refs) {255 let printed;256 try {257 printed = isNewPlugin(plugin)258 ? plugin.serialize(val, config, indentation, depth, refs, printer)259 : plugin.print(260 val,261 valChild => printer(valChild, config, indentation, depth, refs),262 str => {263 const indentationNext = indentation + config.indent;264 return (265 indentationNext +266 str.replace(NEWLINE_REGEXP, '\n' + indentationNext)267 );268 },269 {270 edgeSpacing: config.spacingOuter,271 min: config.min,...

Full Screen

Full Screen

builder.index.entity.plugin.js

Source:builder.index.entity.plugin.js Github

copy

Full Screen

1/*2 * Builder Index controller Plugin entity controller3 */4+function ($) { "use strict";5 if ($.oc.builder === undefined)6 $.oc.builder = {}7 if ($.oc.builder.entityControllers === undefined)8 $.oc.builder.entityControllers = {}9 var Base = $.oc.builder.entityControllers.base,10 BaseProto = Base.prototype11 var Plugin = function(indexController) {12 Base.call(this, 'plugin', indexController)13 this.popupZIndex = 5050 // This popup should be above the flyout overlay, which z-index is 500014 }15 Plugin.prototype = Object.create(BaseProto)16 Plugin.prototype.constructor = Plugin17 // PUBLIC METHODS18 // ============================19 Plugin.prototype.cmdMakePluginActive = function(ev) {20 var $target = $(ev.currentTarget),21 selectedPluginCode = $target.data('pluginCode')22 this.makePluginActive(selectedPluginCode)23 }24 Plugin.prototype.cmdCreatePlugin = function(ev) {25 var $target = $(ev.currentTarget)26 $target.one('shown.oc.popup', this.proxy(this.onPluginPopupShown))27 $target.popup({28 handler: 'onPluginLoadPopup',29 zIndex: this.popupZIndex30 })31 }32 Plugin.prototype.cmdApplyPluginSettings = function(ev) {33 var $form = $(ev.currentTarget),34 self = this35 $.oc.stripeLoadIndicator.show()36 $form.request('onPluginSave').always(37 $.oc.builder.indexController.hideStripeIndicatorProxy38 ).done(function(data){39 $form.trigger('close.oc.popup')40 self.applyPluginSettingsDone(data)41 })42 }43 Plugin.prototype.cmdEditPluginSettings = function(ev) {44 var $target = $(ev.currentTarget)45 $target.one('shown.oc.popup', this.proxy(this.onPluginPopupShown))46 $target.popup({47 handler: 'onPluginLoadPopup',48 zIndex: this.popupZIndex,49 extraData: {50 pluginCode: $target.data('pluginCode')51 }52 })53 }54 // EVENT HANDLERS55 // ============================56 Plugin.prototype.onPluginPopupShown = function(ev, button, popup) {57 $(popup).find('input[name=name]').focus()58 }59 // INTERNAL METHODS60 // ============================61 Plugin.prototype.applyPluginSettingsDone = function(data) {62 if (data.responseData !== undefined && data.responseData.isNewPlugin !== undefined) {63 this.makePluginActive(data.responseData.pluginCode, true)64 }65 }66 Plugin.prototype.makePluginActive = function(pluginCode, updatePluginList) {67 var $form = $('#builder-plugin-selector-panel form').first()68 $.oc.stripeLoadIndicator.show()69 $form.request('onPluginSetActive', {70 data: {71 pluginCode: pluginCode,72 updatePluginList: (updatePluginList ? 1 : 0)73 }74 }).always(75 $.oc.builder.indexController.hideStripeIndicatorProxy76 ).done(77 this.proxy(this.makePluginActiveDone)78 )79 }80 Plugin.prototype.makePluginActiveDone = function(data) {81 var pluginCode = data.responseData.pluginCode82 $('#builder-plugin-selector-panel [data-control=filelist]').fileList('markActive', pluginCode)83 }84 // REGISTRATION85 // ============================86 $.oc.builder.entityControllers.plugin = Plugin;...

Full Screen

Full Screen

build-options.js

Source:build-options.js Github

copy

Full Screen

1'use strict';2const path = require('path').posix;3const _ = require('lodash');4const defaultGens = require('./default-gens');5const validateOptions = require('./validate-options');6function getAddonPublicDir(app) {7 // When SVGJar is used by an addon, the addon's public directory8 // is used as the default source of SVG images.9 return path.join(app.root, app.treePaths.public);10}11function getAppPublicDir(app) {12 // When SVGJar is used by an app, the apps's public directory13 // is used as the default source of SVG images.14 return app.options.trees.public;15}16function getPluginName(plugin) {17 return Object.keys(plugin)[0];18}19function mergeOptimizerPlugins(defaultPlugins, customPlugins) {20 let modifiedPlugins = defaultPlugins.map(defaultPlugin => {21 let pluginName = getPluginName(defaultPlugin);22 let customPlugin = customPlugins.find(23 plugin => plugin[pluginName] !== undefined24 );25 return Object.assign({}, customPlugin || defaultPlugin);26 });27 let newPlugins = customPlugins.filter(customPlugin => {28 let pluginName = getPluginName(customPlugin);29 let isNewPlugin = defaultPlugins.every(30 defaultPlugin => defaultPlugin[pluginName] === undefined31 );32 return isNewPlugin;33 });34 return [...modifiedPlugins, ...newPlugins];35}36function buildOptions(app) {37 let customOpts = app.options.svgJar || {};38 let isDevelopment = app.env === 'development';39 let isUsedByAddon = !!app.parent;40 let defaultSourceDir = isUsedByAddon41 ? getAddonPublicDir(app)42 : getAppPublicDir(app);43 let defaultOpts = {44 rootURL: '/',45 sourceDirs: [defaultSourceDir],46 strategy: 'inline',47 stripPath: true,48 optimizer: {49 plugins: [50 { removeTitle: false },51 { removeDesc: { removeAny: false } },52 { removeViewBox: false },53 ],54 },55 persist: true,56 validations: {57 throwOnFailure: false,58 validateViewBox: true,59 checkForDuplicates: true,60 },61 viewer: {62 enabled: isDevelopment && !isUsedByAddon,63 },64 inline: {65 idGen: defaultGens.inlineIdGen,66 copypastaGen: defaultGens.inlineCopypastaGen,67 },68 symbol: {69 idGen: defaultGens.symbolIdGen,70 copypastaGen: defaultGens.symbolCopypastaGen,71 outputFile: '/assets/symbols.svg',72 prefix: '',73 includeLoader: true,74 containerAttrs: {75 style: 'position: absolute; width: 0; height: 0;',76 width: '0',77 height: '0',78 version: '1.1',79 xmlns: 'http://www.w3.org/2000/svg',80 'xmlns:xlink': 'http://www.w3.org/1999/xlink',81 },82 },83 };84 validateOptions(defaultOpts, customOpts);85 let options = _.merge({}, defaultOpts, customOpts);86 options.strategy = _.castArray(options.strategy);87 if (customOpts.optimizer && customOpts.optimizer.plugins) {88 options.optimizer.plugins = mergeOptimizerPlugins(89 defaultOpts.optimizer.plugins,90 customOpts.optimizer.plugins91 );92 }93 if (customOpts.symbol && customOpts.symbol.containerAttrs) {94 options.symbol.containerAttrs = customOpts.symbol.containerAttrs;95 }96 return options;97}...

Full Screen

Full Screen

postcss-plugin-list.js

Source:postcss-plugin-list.js Github

copy

Full Screen

1const debug = require("@swissquote/crafty-commons/packages/debug")(2 "postcss-swissquote-preset"3);4module.exports = () => {5 const listed = [];6 function reportOnPlugin(plugin) {7 if (!plugin.postcssPlugin) {8 return "- ??? unknown ???";9 }10 const isNewPlugin = listed.indexOf(plugin.postcssPlugin) > -1;11 listed.push(plugin.postcssPlugin);12 return `- ${plugin.postcssPlugin} ${isNewPlugin ? " (duplicate)" : ""}`;13 }14 return {15 postcssPlugin: "plugin-list",16 Once(root, { result }) {17 const plugins = result.processor.plugins.map(reportOnPlugin);18 debug("Used plugins:", plugins.join("\n"));19 }20 };21};...

Full Screen

Full Screen

Jest Testing Tutorial

LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.

Chapters

  1. What is Jest Framework
  2. Advantages of Jest - Jest has 3,898,000 GitHub repositories, as mentioned on its official website. Learn what makes Jest special and why Jest has gained popularity among the testing and developer community.
  3. Jest Installation - All the prerequisites and set up steps needed to help you start Jest automation testing.
  4. Using Jest with NodeJS Project - Learn how to leverage Jest framework to automate testing using a NodeJS Project.
  5. Writing First Test for Jest Framework - Get started with code-based tutorial to help you write and execute your first Jest framework testing script.
  6. Jest Vocabulary - Learn the industry renowned and official jargons of the Jest framework by digging deep into the Jest vocabulary.
  7. Unit Testing with Jest - Step-by-step tutorial to help you execute unit testing with Jest framework.
  8. Jest Basics - Learn about the most pivotal and basic features which makes Jest special.
  9. Jest Parameterized Tests - Avoid code duplication and fasten automation testing with Jest using parameterized tests. Parameterization allows you to trigger the same test scenario over different test configurations by incorporating parameters.
  10. Jest Matchers - Enforce assertions better with the help of matchers. Matchers help you compare the actual output with the expected one. Here is an example to see if the object is acquired from the correct class or not. -

|<p>it('check_object_of_Car', () => {</p><p> expect(newCar()).toBeInstanceOf(Car);</p><p> });</p>| | :- |

  1. Jest Hooks: Setup and Teardown - Learn how to set up conditions which needs to be followed by the test execution and incorporate a tear down function to free resources after the execution is complete.
  2. Jest Code Coverage - Unsure there is no code left unchecked in your application. Jest gives a specific flag called --coverage to help you generate code coverage.
  3. HTML Report Generation - Learn how to create a comprehensive HTML report based on your Jest test execution.
  4. Testing React app using Jest Framework - Learn how to test your react web-application with Jest framework in this detailed Jest tutorial.
  5. Test using LambdaTest cloud Selenium Grid - Run your Jest testing script over LambdaTest cloud-based platform and leverage parallel testing to help trim down your test execution time.
  6. Snapshot Testing for React Front Ends - Capture screenshots of your react based web-application and compare them automatically for visual anomalies with the help of Jest tutorial.
  7. Bonus: Import ES modules with Jest - ES modules are also known as ECMAScript modules. Learn how to best use them by importing in your Jest testing scripts.
  8. Jest vs Mocha vs Jasmine - Learn the key differences between the most popular JavaScript-based testing frameworks i.e. Jest, Mocha, and Jasmine.
  9. Jest FAQs(Frequently Asked Questions) - Explore the most commonly asked questions around Jest framework, with their answers.

Run Jest 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