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

Update karma.conf.js to fix test #1163

Closed
wants to merge 3 commits into from
Closed
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
28 changes: 28 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Forked from: https://github.com/angular/components/blob/8ac3ca11add4ae194b2b79169559fb3dbad7e161/tools/BUILD.bazel
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@io_bazel_rules_webtesting//web:web.bzl", "browser")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -34,3 +35,30 @@ config_setting(
name = "stamp",
values = {"stamp": "true"},
)

PLATFORM_METADATA = select({
"@npm//@angular/build-tooling/bazel/constraints:linux_x64": [
"@org_chromium_chromedriver_linux_x64//:metadata",
"@org_chromium_chromium_linux_x64//:metadata",
],
"@npm//@angular/build-tooling/bazel/constraints:macos_x64": [
"@org_chromium_chromedriver_macos_x64//:metadata",
"@org_chromium_chromium_macos_x64//:metadata",
],
"@npm//@angular/build-tooling/bazel/constraints:macos_arm64": [
"@org_chromium_chromedriver_macos_arm64//:metadata",
"@org_chromium_chromium_macos_arm64//:metadata",
],
"@npm//@angular/build-tooling/bazel/constraints:windows_x64": [
"@org_chromium_chromedriver_windows//:metadata",
"@org_chromium_chromium_windows//:metadata",
],
})

browser(
name = "chromium",
metadata = "chromium.json",
deps = PLATFORM_METADATA + [
"@io_bazel_rules_webtesting//go/wsl",
],
)
17 changes: 17 additions & 0 deletions tools/chromium.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"environment": "local",
"capabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"binary": "%FILE:CHROMIUM%",
"args": ["--no-sandbox", "--headless", "--use-gl=swiftshader-webgl"]
},
"google:wslConfig": {
"binary": "%FILE:CHROMEDRIVER%",
"port": "%WSLPORT:WSL%",
"args": ["--port=%WSLPORT:WSL%"],
"status": true,
"shutdown": true
}
}
}
2 changes: 1 addition & 1 deletion tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def karma_web_test_suite(name, **kwargs):

kwargs["tags"] = ["native"] + kwargs.get("tags", [])
kwargs["browsers"] = [
"@npm//@angular/build-tooling/bazel/browsers/chromium:chromium",
"//tools:chromium",
]

# Filter out options which are specific to "karma_web_test" targets. We cannot
Expand Down
84 changes: 42 additions & 42 deletions tools/test/bazel-karma-local-config.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
// Forked from: https://github.com/angular/components/blob/8ac3ca11add4ae194b2b79169559fb3dbad7e161/test/bazel-karma-local-config.js
/**
* Karma configuration that is used by Bazel karma_web_test targets which do not
* want to launch any browser and just enable manual browser debugging.
*/
// // Forked from: https://github.com/angular/components/blob/8ac3ca11add4ae194b2b79169559fb3dbad7e161/test/bazel-karma-local-config.js
// /**
// * Karma configuration that is used by Bazel karma_web_test targets which do not
// * want to launch any browser and just enable manual browser debugging.
// */

module.exports = (config) => {
const overwrites = {};
// module.exports = (config) => {
// const overwrites = {};

// By default "@bazel/concatjs" configures Chrome as browser. Since we don't want
// to launch any browser at all, we overwrite the "browsers" option. Since the
// default config tries to extend the browsers array with "Chrome", we need to
// always return a new empty array.
Object.defineProperty(overwrites, 'browsers', {
get: () => [],
set: () => {},
enumerable: true,
});
// // By default "@bazel/concatjs" configures Chrome as browser. Since we don't want
// // to launch any browser at all, we overwrite the "browsers" option. Since the
// // default config tries to extend the browsers array with "Chrome", we need to
// // always return a new empty array.
// Object.defineProperty(overwrites, 'browsers', {
// get: () => [],
// set: () => {},
// enumerable: true,
// });

// Ensures that tests start executing once browsers have been manually connected. We need
// to use "defineProperty" because the default "@bazel/concatjs" config overwrites the option.
Object.defineProperty(overwrites, 'autoWatch', {
get: () => true,
set: () => {},
enumerable: true,
});
// // Ensures that tests start executing once browsers have been manually connected. We need
// // to use "defineProperty" because the default "@bazel/concatjs" config overwrites the option.
// Object.defineProperty(overwrites, 'autoWatch', {
// get: () => true,
// set: () => {},
// enumerable: true,
// });

// When not running with ibazel, do not set up the `@bazel/concatjs` watcher. This one
// relies on ibazel to write to the `stdin` interface. When running without ibazel, the
// watcher will kill concatjs since there is no data written to the `stdin` interface.
if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
// We pre-define a plugins array that captures registration of Karma plugins
// and unsets the watcher definitions so that no watcher can be configured.
overwrites.plugins = new KarmaPluginArrayWithoutWatchers();
}
// // When not running with ibazel, do not set up the `@bazel/concatjs` watcher. This one
// // relies on ibazel to write to the `stdin` interface. When running without ibazel, the
// // watcher will kill concatjs since there is no data written to the `stdin` interface.
// if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
// // We pre-define a plugins array that captures registration of Karma plugins
// // and unsets the watcher definitions so that no watcher can be configured.
// overwrites.plugins = new KarmaPluginArrayWithoutWatchers();
// }

config.set(overwrites);
};
// config.set(overwrites);
// };

class KarmaPluginArrayWithoutWatchers extends Array {
// The Bazel Karma rules only register new plugins using `.push`.
push(...plugins) {
plugins
.filter((p) => typeof p === 'object')
.forEach((p) => delete p.watcher);
// class KarmaPluginArrayWithoutWatchers extends Array {
// // The Bazel Karma rules only register new plugins using `.push`.
// push(...plugins) {
// plugins
// .filter((p) => typeof p === 'object')
// .forEach((p) => delete p.watcher);

super.push(...plugins);
}
}
// super.push(...plugins);
// }
// }
Loading
Loading