Best JavaScript code snippet using ng-mocks
command.start.js
Source:command.start.js
1"use strict";2var path = require("path");3var fs = require("fs");4var _ = require("../../lodash.custom");5var utils = require("../utils");6var opts = require("./cli-options").utils;7/**8 * $ browser-sync start <options>9 *10 * This commands starts the Browsersync servers11 * & Optionally UI.12 *13 * @param opts14 * @returns {Function}15 */16module.exports = function (opts) {17 var flags = preprocessFlags(opts.cli.flags);18 var maybepkg = path.resolve(process.cwd(), "package.json");19 var input = flags;20 if (flags.config) {21 var maybeconf = path.resolve(process.cwd(), flags.config);22 if (fs.existsSync(maybeconf)) {23 var conf = require(maybeconf);24 input = _.merge({}, conf, flags);25 } else {26 utils.fail(true, new Error("Configuration file '" + flags.config + "' not found"), opts.cb);27 }28 } else {29 if (fs.existsSync(maybepkg)) {30 var pkg = require(maybepkg);31 if (pkg["browser-sync"]) {32 console.log("> Configuration obtained from package.json");33 input = _.merge({}, pkg["browser-sync"], flags);34 }35 }36 }37 return require("../../")38 .create("cli")39 .init(input, opts.cb);40};41/**42 * @param flags43 * @returns {*}44 */45function preprocessFlags (flags) {46 return [47 stripUndefined,48 legacyFilesArgs49 ].reduce(function (flags, fn) {50 return fn.call(null, flags);51 }, flags);52}53/**54 * Incoming undefined values are problematic as55 * they interfere with Immutable.Map.mergeDeep56 * @param subject57 * @returns {*}58 */59function stripUndefined (subject) {60 return Object.keys(subject).reduce(function (acc, key) {61 var value = subject[key];62 if (typeof value === "undefined") {63 return acc;64 }65 acc[key] = value;66 return acc;67 }, {});68}69/**70 * @param flags71 * @returns {*}72 */73function legacyFilesArgs(flags) {74 if (flags.files && flags.files.length) {75 flags.files = flags.files.reduce(function (acc, item) {76 return acc.concat(opts.explodeFilesArg(item));77 }, []);78 }79 return flags;...
Check out the latest blogs from LambdaTest on this topic:
In today’s tech world, where speed is the key to modern software development, we should aim to get quick feedback on the impact of any change, and that is where CI/CD comes in place.
Have you ever struggled with handling hidden elements while automating a web or mobile application? I was recently automating an eCommerce application. I struggled with handling hidden elements on the web page.
We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.
Joseph, who has been working as a Quality Engineer, was assigned to perform web automation for the company’s website.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
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!!