MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / ignore

Function ignore

javascript/selenium-webdriver/testing/index.js:576–609  ·  view source on GitHub ↗

* Returns an object with wrappers for the standard mocha/jasmine test * functions: `describe` and `it`, which will redirect to `xdescribe` and `xit`, * respectively, if provided predicate function returns false. * * Sample usage: * * const {Browser} = require('selenium-webdriver'); *

(predicateFn)

Source from the content-addressed store, hash-verified

574 * versions of the `describe` and `it` test functions.
575 */
576function ignore(predicateFn) {
577 const isJasmine = global.jasmine && typeof global.jasmine === 'object'
578
579 const hooks = {
580 describe: getTestHook('describe'),
581 xdescribe: getTestHook('xdescribe'),
582 it: getTestHook('it'),
583 xit: getTestHook('xit'),
584 }
585 hooks.fdescribe = isJasmine ? getTestHook('fdescribe') : hooks.describe.only
586 hooks.fit = isJasmine ? getTestHook('fit') : hooks.it.only
587
588 let describe = wrap(hooks.xdescribe, hooks.describe)
589 let fdescribe = wrap(hooks.xdescribe, hooks.fdescribe)
590 //eslint-disable-next-line no-only-tests/no-only-tests
591 describe.only = fdescribe
592
593 let it = wrap(hooks.xit, hooks.it)
594 let fit = wrap(hooks.xit, hooks.fit)
595 //eslint-disable-next-line no-only-tests/no-only-tests
596 it.only = fit
597
598 return { describe, it }
599
600 function wrap(onSkip, onRun) {
601 return function (...args) {
602 if (predicateFn()) {
603 onSkip(...args)
604 } else {
605 onRun(...args)
606 }
607 }
608 }
609}
610
611/**
612 * @param {string} name

Calls 2

getTestHookFunction · 0.85
wrapFunction · 0.70

Tested by

no test coverage detected