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

Function suite

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

* Defines a test suite by calling the provided function once for each of the * target browsers. If a suite is not limited to a specific set of browsers in * the provided plain ./index.SuiteOptions suite options, the suite will * be configured to run against each of the {@linkplain ./index.

(fn, options = undefined)

Source from the content-addressed store, hash-verified

468 * @param {SuiteOptions=} options configuration options.
469 */
470function suite(fn, options = undefined) {
471 if (inSuite) {
472 throw Error('Calls to suite() may not be nested')
473 }
474 try {
475 init()
476 inSuite = true
477
478 const suiteBrowsers = new Map()
479 if (options && options.browsers) {
480 for (let browser of options.browsers) {
481 if (typeof browser === 'string') {
482 suiteBrowsers.set(browser, { name: browser })
483 } else {
484 suiteBrowsers.set(browser.name, browser)
485 }
486 }
487 }
488
489 for (let browser of targetBrowsers) {
490 if (suiteBrowsers.size > 0 && !suiteBrowsers.has(browser.name)) {
491 continue
492 }
493
494 describe(`[${browser.name}]`, function () {
495 if (!seleniumUrl && seleniumJar && !seleniumServer) {
496 seleniumServer = new remote.SeleniumServer(seleniumJar, {
497 java: bazelJava(),
498 loopback: true,
499 args: ['--host', '127.0.0.1', ...pinnedGridArgs(targetBrowsers.map((b) => b.name))],
500 })
501
502 const startTimeout = 65 * 1000
503
504 function startSelenium() {
505 if (typeof this.timeout === 'function') {
506 this.timeout(startTimeout) // For mocha.
507 }
508
509 info(`Starting selenium server ${seleniumJar}`)
510 return seleniumServer.start(60 * 1000)
511 }
512
513 const /** !Function */ beforeHook = global.beforeAll || global.before
514 beforeHook(startSelenium, startTimeout)
515 }
516
517 fn(new Environment(browser, seleniumUrl || seleniumServer))
518 })
519 }
520 } finally {
521 inSuite = false
522 }
523}
524
525/**
526 * Returns an object with wrappers for the standard mocha/jasmine test

Calls 8

initFunction · 0.85
bazelJavaFunction · 0.85
pinnedGridArgsFunction · 0.85
fnFunction · 0.85
setMethod · 0.65
ErrorFunction · 0.50
hasMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected