Path: blob/trunk/javascript/selenium-webdriver/lib/test/index.js
2884 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617'use strict'1819//const build = require('./build')20const fileserver = require('./fileserver')21const logging = require('selenium-webdriver/lib/logging')22const testing = require('selenium-webdriver/testing')2324//const NO_BUILD = /^1|true$/i.test(process.env['SELENIUM_NO_BUILD'])2526/**27* @param {function(!testing.Environment)} fn The top level suite function.28* @param {testing.SuiteOptions=} options Suite specific options.29*/30function suite(fn, options = undefined) {31testing.suite(function (env) {32/*33before(function () {34if (false && !NO_BUILD) {35return build36.of(37'//javascript/atoms/fragments:is-displayed',38'//javascript/webdriver/atoms:get-attribute'39)40.onlyOnce()41.go()42}43})44*/45fn(env)46}, options)47}4849// GLOBAL TEST SETUP5051process.on('unhandledRejection', (reason) => {52console.error('Unhandled promise rejection:', reason)53})5455if (/^1|true$/i.test(process.env['SELENIUM_VERBOSE'])) {56logging.installConsoleHandler()57logging.getLogger(`${logging.Type.DRIVER}.http`).setLevel(logging.Level.ALL)58}5960testing.init()6162before(function () {63// Do not pass register fileserver.start directly with testing.before,64// as start takes an optional port, which before assumes is an async65// callback.66return fileserver.start()67})6869after(function () {70return fileserver.stop()71})7273// PUBLIC API7475exports.suite = suite76exports.ignore = testing.ignore77exports.Pages = fileserver.Pages78exports.whereIs = fileserver.whereIs798081