* 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)
| 419 | * @param {SuiteOptions=} options configuration options. |
| 420 | */ |
| 421 | function suite(fn, options = undefined) { |
| 422 | if (inSuite) { |
| 423 | throw Error('Calls to suite() may not be nested') |
| 424 | } |
| 425 | try { |
| 426 | init() |
| 427 | inSuite = true |
| 428 | |
| 429 | const suiteBrowsers = new Map() |
| 430 | if (options && options.browsers) { |
| 431 | for (let browser of options.browsers) { |
| 432 | if (typeof browser === 'string') { |
| 433 | suiteBrowsers.set(browser, { name: browser }) |
| 434 | } else { |
| 435 | suiteBrowsers.set(browser.name, browser) |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | for (let browser of targetBrowsers) { |
| 441 | if (suiteBrowsers.size > 0 && !suiteBrowsers.has(browser.name)) { |
| 442 | continue |
| 443 | } |
| 444 | |
| 445 | describe(`[${browser.name}]`, function () { |
| 446 | if (!seleniumUrl && seleniumJar && !seleniumServer) { |
| 447 | seleniumServer = new remote.SeleniumServer(seleniumJar) |
| 448 | |
| 449 | const startTimeout = 65 * 1000 |
| 450 | |
| 451 | function startSelenium() { |
| 452 | if (typeof this.timeout === 'function') { |
| 453 | this.timeout(startTimeout) // For mocha. |
| 454 | } |
| 455 | |
| 456 | info(`Starting selenium server ${seleniumJar}`) |
| 457 | return seleniumServer.start(60 * 1000) |
| 458 | } |
| 459 | |
| 460 | const /** !Function */ beforeHook = global.beforeAll || global.before |
| 461 | beforeHook(startSelenium, startTimeout) |
| 462 | } |
| 463 | |
| 464 | fn(new Environment(browser, seleniumUrl || seleniumServer)) |
| 465 | }) |
| 466 | } |
| 467 | } finally { |
| 468 | inSuite = false |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * Returns an object with wrappers for the standard mocha/jasmine test |
no test coverage detected