Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/lib/test/index.js
2884 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
'use strict'
19
20
//const build = require('./build')
21
const fileserver = require('./fileserver')
22
const logging = require('selenium-webdriver/lib/logging')
23
const testing = require('selenium-webdriver/testing')
24
25
//const NO_BUILD = /^1|true$/i.test(process.env['SELENIUM_NO_BUILD'])
26
27
/**
28
* @param {function(!testing.Environment)} fn The top level suite function.
29
* @param {testing.SuiteOptions=} options Suite specific options.
30
*/
31
function suite(fn, options = undefined) {
32
testing.suite(function (env) {
33
/*
34
before(function () {
35
if (false && !NO_BUILD) {
36
return build
37
.of(
38
'//javascript/atoms/fragments:is-displayed',
39
'//javascript/webdriver/atoms:get-attribute'
40
)
41
.onlyOnce()
42
.go()
43
}
44
})
45
*/
46
fn(env)
47
}, options)
48
}
49
50
// GLOBAL TEST SETUP
51
52
process.on('unhandledRejection', (reason) => {
53
console.error('Unhandled promise rejection:', reason)
54
})
55
56
if (/^1|true$/i.test(process.env['SELENIUM_VERBOSE'])) {
57
logging.installConsoleHandler()
58
logging.getLogger(`${logging.Type.DRIVER}.http`).setLevel(logging.Level.ALL)
59
}
60
61
testing.init()
62
63
before(function () {
64
// Do not pass register fileserver.start directly with testing.before,
65
// as start takes an optional port, which before assumes is an async
66
// callback.
67
return fileserver.start()
68
})
69
70
after(function () {
71
return fileserver.stop()
72
})
73
74
// PUBLIC API
75
76
exports.suite = suite
77
exports.ignore = testing.ignore
78
exports.Pages = fileserver.Pages
79
exports.whereIs = fileserver.whereIs
80
81