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

Function suite

javascript/selenium-webdriver/testing/index.js:496–549  ·  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

494 * @param {SuiteOptions=} options configuration options.
495 */
496function suite(fn, options = undefined) {
497 if (inSuite) {
498 throw Error('Calls to suite() may not be nested')
499 }
500 try {
501 init()
502 inSuite = true
503
504 const suiteBrowsers = new Map()
505 if (options && options.browsers) {
506 for (let browser of options.browsers) {
507 if (typeof browser === 'string') {
508 suiteBrowsers.set(browser, { name: browser })
509 } else {
510 suiteBrowsers.set(browser.name, browser)
511 }
512 }
513 }
514
515 for (let browser of targetBrowsers) {
516 if (suiteBrowsers.size > 0 && !suiteBrowsers.has(browser.name)) {
517 continue
518 }
519
520 describe(`[${browser.name}]`, function () {
521 if (!seleniumUrl && seleniumJar && !seleniumServer) {
522 seleniumServer = new remote.SeleniumServer(seleniumJar, {
523 java: bazelJava(),
524 loopback: true,
525 args: ['--host', '127.0.0.1', ...gridArgs(targetBrowsers.map((b) => b.name))],
526 })
527
528 const startTimeout = 65 * 1000
529
530 function startSelenium() {
531 if (typeof this.timeout === 'function') {
532 this.timeout(startTimeout) // For mocha.
533 }
534
535 info(`Starting selenium server ${seleniumJar}`)
536 return seleniumServer.start(60 * 1000)
537 }
538
539 const /** !Function */ beforeHook = global.beforeAll || global.before
540 beforeHook(startSelenium, startTimeout)
541 }
542
543 fn(new Environment(browser, seleniumUrl || seleniumServer))
544 })
545 }
546 } finally {
547 inSuite = false
548 }
549}
550
551/**
552 * Returns an object with wrappers for the standard mocha/jasmine test

Calls 8

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

Tested by

no test coverage detected