How to use createMissingArgumentError method in Mocha

Best JavaScript code snippet using mocha

errors.js

Source:errors.js Github

copy

Full Screen

...67 * @param {string} argument - Argument name.68 * @param {string} expected - Expected argument datatype.69 * @returns {Error} instance detailing the error condition70 */71function createMissingArgumentError(message, argument, expected) {72 return createInvalidArgumentTypeError(message, argument, expected);73}74/**75 * Creates an error object to be thrown when an argument did not use the supported type76 *77 * @public78 * @param {string} message - Error message to be displayed.79 * @param {string} argument - Argument name.80 * @param {string} expected - Expected argument datatype.81 * @returns {Error} instance detailing the error condition82 */83function createInvalidArgumentTypeError(message, argument, expected) {84 var err = new TypeError(message);85 err.code = 'ERR_MOCHA_INVALID_ARG_TYPE';...

Full Screen

Full Screen

lookup-files.js

Source:lookup-files.js Github

copy

Full Screen

...116 // ignore error117 return;118 }119 if (!extensions.length) {120 throw createMissingArgumentError(121 format(122 'Argument %s required when argument %s is a directory',123 sQuote('extensions'),124 sQuote('filepath')125 ),126 'extensions',127 'array'128 );129 }130 if (131 !stat.isFile() ||132 !hasMatchingExtname(pathname, extensions) ||133 isHiddenOnUnix(pathname)134 ) {...

Full Screen

Full Screen

common.js

Source:common.js Github

copy

Full Screen

2// Based on mocha v6.1.3 under the MIT license.3// Original copyright (c) 2011-2018 JS Foundation and contributors,4// https://js.foundation5const Suite = require('@arangodb/mocha/suite');6function createMissingArgumentError(message, argument, expected) {7 var err = new TypeError(message);8 err.code = 'ERR_MOCHA_INVALID_ARG_TYPE';9 err.argument = argument;10 err.expected = expected;11 err.actual = typeof argument;12 return err;13}14module.exports = function(suites, context, mocha) {15 function shouldBeTested(suite) {16 return (17 !mocha.options.grep ||18 (mocha.options.grep &&19 mocha.options.grep.test(suite.fullTitle()) &&20 !mocha.options.invert)21 );22 }23 return {24 runWithSuite: function runWithSuite(suite) {25 return function run() {26 suite.run();27 };28 },29 before: function(name, fn) {30 suites[0].beforeAll(name, fn);31 },32 after: function(name, fn) {33 suites[0].afterAll(name, fn);34 },35 beforeEach: function(name, fn) {36 suites[0].beforeEach(name, fn);37 },38 afterEach: function(name, fn) {39 suites[0].afterEach(name, fn);40 },41 suite: {42 only: function only(opts) {43 opts.isOnly = true;44 return this.create(opts);45 },46 skip: function skip(opts) {47 opts.pending = true;48 return this.create(opts);49 },50 create: function create(opts) {51 var suite = Suite.create(suites[0], opts.title);52 suite.pending = Boolean(opts.pending);53 suite.file = opts.file;54 suites.unshift(suite);55 if (opts.isOnly) {56 if (mocha.options.forbidOnly && shouldBeTested(suite)) {57 throw new Error('`.only` forbidden');58 }59 suite.parent.appendOnlySuite(suite);60 }61 if (suite.pending) {62 if (mocha.options.forbidPending && shouldBeTested(suite)) {63 throw new Error('Pending test forbidden');64 }65 }66 if (typeof opts.fn === 'function') {67 opts.fn.call(suite);68 suites.shift();69 } else if (typeof opts.fn === 'undefined' && !suite.pending) {70 throw createMissingArgumentError(71 'Suite "' +72 suite.fullTitle() +73 '" was defined but no callback was supplied. ' +74 'Supply a callback or explicitly skip the suite.',75 'callback',76 'function'77 );78 } else if (!opts.fn && suite.pending) {79 suites.shift();80 }81 return suite;82 }83 },84 test: {...

Full Screen

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 Mocha 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