Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bazel + js]: Get small js tests running on the rbe #14123

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .github/workflows/ci-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ jobs:
cache-key: javascript-build
run: bazel build //javascript/node/selenium-webdriver:selenium-webdriver

small-tests:
name: Small Tests
needs: build
uses: ./.github/workflows/bazel.yml
with:
name: Small Tests
cache-key: javascript-small-tests
run: bazel test //javascript/node/selenium-webdriver:small-tests

browser-tests:
name: Browser Tests
needs: small-tests
needs: build
uses: ./.github/workflows/bazel.yml
strategy:
fail-fast: false
Expand Down
16 changes: 6 additions & 10 deletions javascript/node/selenium-webdriver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ js_library(
"common/*.js",
"bidi/*.js",
]),
deps = [
":node_modules/jszip",
":node_modules/tmp",
":node_modules/ws",
],
)

npm_package(
Expand Down Expand Up @@ -117,27 +122,18 @@ js_library(
mocha_test(
name = "small-tests",
size = "small",
args = ["./**/*test.js"],
chdir = package_name(),
data = [
":node_modules/@bazel/runfiles",
":node_modules/jszip",
":node_modules/mocha",
":node_modules/mocha-junit-reporter",
":node_modules/sinon",
":node_modules/tmp",
":node_modules/ws",
":small-test-srcs",
":test-data",
"//:node_modules/selenium-webdriver",
"//common/extensions:js-lib",
"//common/src/web:js-lib",
"//javascript/node/selenium-webdriver/lib/atoms:find-elements",
"//javascript/node/selenium-webdriver/lib/atoms:get_attribute",
"//javascript/node/selenium-webdriver/lib/atoms:is_displayed",
"//javascript/node/selenium-webdriver/lib/atoms:mutation-listener",
],
tags = [
"skip-remote",
],
)

Expand Down
8 changes: 4 additions & 4 deletions javascript/node/selenium-webdriver/test/driver_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
const fs = require('node:fs')
const os = require('node:os')
const path = require('node:path')
const { Browser } = require('../index')
const { Environment } = require('../testing')
const chrome = require('../chrome')
const firefox = require('../firefox')
const { Browser } = require('selenium-webdriver/index')
const { Environment } = require('selenium-webdriver/testing')
const chrome = require('selenium-webdriver/chrome')
const firefox = require('selenium-webdriver/firefox')
const { runfiles } = require('@bazel/runfiles')

function GetBrowserForTests() {
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/test/io/io_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const assert = require('node:assert'),
fs = require('node:fs'),
path = require('node:path')

const io = require('../../io')
const io = require('selenium-webdriver/io')

describe('io', function () {
describe('copy', function () {
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/test/io/zip_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const assert = require('node:assert')
const fs = require('node:fs')
const path = require('node:path')

const io = require('../../io')
const zip = require('../../io/zip')
const { InvalidArgumentError } = require('../../lib/error')
const io = require('selenium-webdriver/io')
const zip = require('selenium-webdriver/io/zip')
const { InvalidArgumentError } = require('selenium-webdriver/lib/error')
const { locate } = require('../../lib/test/resources')

const XPI_PATH = locate('common/extensions/webextensions-selenium-example.xpi')
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/test/lib/by_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict'

const assert = require('node:assert')
const by = require('../../lib/by')
const by = require('selenium-webdriver/lib/by')

describe('by', function () {
describe('By', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict'

const assert = require('node:assert')
const virtualAuthenticatorCredential = require('../../lib/virtual_authenticator').Credential
const virtualAuthenticatorCredential = require('selenium-webdriver/lib/virtual_authenticator').Credential

describe('Credentials', function () {
const BASE64_ENCODED_PK = `MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDbBOu5Lhs4vpowbCnmCyLUpIE7JM9sm9QXzye2G+jr+Kr
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/test/lib/error_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

describe('error', function () {
let assert = require('node:assert')
let error = require('../../lib/error')
let error = require('selenium-webdriver/lib/error')

describe('encodeError', function () {
describe('defaults to an unknown error', function () {
Expand Down
14 changes: 7 additions & 7 deletions javascript/node/selenium-webdriver/test/lib/http_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
const assert = require('node:assert'),
sinon = require('sinon')

const Capabilities = require('../../lib/capabilities').Capabilities,
Command = require('../../lib/command').Command,
CommandName = require('../../lib/command').Name,
error = require('../../lib/error'),
http = require('../../lib/http'),
Session = require('../../lib/session').Session,
WebElement = require('../../lib/webdriver').WebElement
const Capabilities = require('selenium-webdriver/lib/capabilities').Capabilities,
Command = require('selenium-webdriver/lib/command').Command,
CommandName = require('selenium-webdriver/lib/command').Name,
error = require('selenium-webdriver/lib/error'),
http = require('selenium-webdriver/lib/http'),
Session = require('selenium-webdriver/lib/session').Session,
WebElement = require('selenium-webdriver/lib/webdriver').WebElement

describe('http', function () {
describe('buildPath', function () {
Expand Down
8 changes: 4 additions & 4 deletions javascript/node/selenium-webdriver/test/lib/input_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
'use strict'

const assert = require('node:assert')
const command = require('../../lib/command')
const error = require('../../lib/error')
const input = require('../../lib/input')
const { WebElement } = require('../../lib/webdriver')
const command = require('selenium-webdriver/lib/command')
const error = require('selenium-webdriver/lib/error')
const input = require('selenium-webdriver/lib/input')
const { WebElement } = require('selenium-webdriver/lib/webdriver')

describe('input.Actions', function () {
class StubExecutor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const assert = require('node:assert')
const sinon = require('sinon')
const logging = require('../../lib/logging')
const logging = require('selenium-webdriver/lib/logging')

describe('logging', function () {
let mgr, root, clock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const assert = require('node:assert')

const testutil = require('./testutil')
const promise = require('../../lib/promise')
const promise = require('selenium-webdriver/lib/promise')

// Aliases for readability.
const NativePromise = Promise
Expand Down
10 changes: 5 additions & 5 deletions javascript/node/selenium-webdriver/test/lib/until_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

const assert = require('node:assert')

const By = require('../../lib/by').By
const CommandName = require('../../lib/command').Name
const error = require('../../lib/error')
const until = require('../../lib/until')
const webdriver = require('../../lib/webdriver')
const By = require('selenium-webdriver/lib/by').By
const CommandName = require('selenium-webdriver/lib/command').Name
const error = require('selenium-webdriver/lib/error')
const until = require('selenium-webdriver/lib/until')
const webdriver = require('selenium-webdriver/lib/webdriver')
const WebElement = webdriver.WebElement

describe('until', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
'use strict'

const assert = require('node:assert')
const virtualAuthenticatorOptions = require('../../lib/virtual_authenticator').VirtualAuthenticatorOptions
const Transport = require('../../lib/virtual_authenticator').Transport
const Protocol = require('../../lib/virtual_authenticator').Protocol
const virtualAuthenticatorOptions = require('selenium-webdriver/lib/virtual_authenticator').VirtualAuthenticatorOptions
const Transport = require('selenium-webdriver/lib/virtual_authenticator').Transport
const Protocol = require('selenium-webdriver/lib/virtual_authenticator').Protocol

let options

Expand Down
18 changes: 9 additions & 9 deletions javascript/node/selenium-webdriver/test/lib/webdriver_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

const { StubError, assertIsInstance, assertIsStubError, throwStubError } = require('./testutil')

const error = require('../../lib/error')
const logging = require('../../lib/logging')
const promise = require('../../lib/promise')
const until = require('../../lib/until')
const { Alert, AlertPromise, WebDriver, WebElement, WebElementPromise } = require('../../lib/webdriver')
const { By } = require('../../lib/by')
const { Capabilities } = require('../../lib/capabilities')
const { Name } = require('../../lib/command')
const { Session } = require('../../lib/session')
const error = require('selenium-webdriver/lib/error')
const logging = require('selenium-webdriver/lib/logging')
const promise = require('selenium-webdriver/lib/promise')
const until = require('selenium-webdriver/lib/until')
const { Alert, AlertPromise, WebDriver, WebElement, WebElementPromise } = require('selenium-webdriver/lib/webdriver')
const { By } = require('selenium-webdriver/lib/by')
const { Capabilities } = require('selenium-webdriver/lib/capabilities')
const { Name } = require('selenium-webdriver/lib/command')
const { Session } = require('selenium-webdriver/lib/session')
const assert = require('node:assert')

const CName = Name
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/test/logging_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const assert = require('node:assert')
const test = require('../lib/test')
const { Browser, logging } = require('..')
const { Browser, logging } = require('selenium-webdriver')

test.suite(function (env) {
// Logging API is not supported in IE.
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/test/net/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict'

const assert = require('node:assert')
const net = require('../../net')
const net = require('selenium-webdriver/net')

describe('net.splitHostAndPort', function () {
it('hostname with no port', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const assert = require('node:assert')
const net = require('node:net')
const portprober = require('../../net/portprober')
const portprober = require('selenium-webdriver/net/portprober')
const host = '127.0.0.1'

describe('isFree', function () {
Expand Down
25 changes: 16 additions & 9 deletions javascript/private/mocha_test.bzl
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
load("@npm//javascript/node/selenium-webdriver:mocha/package_json.bzl", mocha_bin = "bin")

def mocha_test(name, deps = [], args = [], data = [], env = {}, **kwargs):
env = dict(env, **{
# Add environment variable so that mocha writes its test xml
# to the location Bazel expects.
"MOCHA_FILE": "$$XML_OUTPUT_FILE",
})
_TIMEOUTS = {
"small": "60000",
"medium": "300000",
"large": "900000",
}

def mocha_test(name, args = [], env = {}, size = None, **kwargs):
mocha_bin.mocha_test(
name = name,
args = args,
data = data,
env = env,
size = size,
args = args + [
"--timeout",
_TIMEOUTS.get(size, "60000"),
],
env = env | {
# Add environment variable so that mocha writes its test xml
# to the location Bazel expects.
"MOCHA_FILE": "$$XML_OUTPUT_FILE",
},
**kwargs
)
Loading