How to use preProcessFlags method in ng-mocks

Best JavaScript code snippet using ng-mocks

command.start.js

Source:command.start.js Github

copy

Full Screen

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;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { preProcessFlags } from 'ng-mocks';2import { mockModule } from 'ng-mocks';3import { AppModule } from './app.module';4const flags = preProcessFlags(AppModule);5mockModule(AppModule, flags);6import './test';

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks 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