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

feat(karma): npm peer deps & remove @rules_webtesting//browsers/sauce:chrome-win10 support #1346

Merged
merged 1 commit into from
Nov 14, 2019
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
7 changes: 7 additions & 0 deletions examples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
"core-js": "2.6.9",
"firebase-tools": "7.1.0",
"history-server": "^1.3.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "2.0.1",
"karma-requirejs": "1.1.0",
"karma-sourcemap-loader": "0.3.7",
"requirejs": "2.3.6",
"rollup": "^1.21.4",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
Expand Down
7 changes: 7 additions & 0 deletions examples/angular_view_engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@
"core-js": "2.6.9",
"firebase-tools": "7.1.0",
"history-server": "^1.3.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "2.0.1",
"karma-requirejs": "1.1.0",
"karma-sourcemap-loader": "0.3.7",
"patch-package": "^6.2.0",
"requirejs": "2.3.6",
"rollup": "^1.21.4",
"rollup-plugin-amd": "^4.0.0",
"rollup-plugin-commonjs": "^10.1.0",
Expand Down
7 changes: 7 additions & 0 deletions examples/protocol_buffers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
"@types/long": "^4.0.0",
"@types/node": "11.11.1",
"http-server": "^0.11.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "2.0.1",
"karma-requirejs": "1.1.0",
"karma-sourcemap-loader": "0.3.7",
"long": "4.0.0",
"protobufjs": "5.0.3",
"requirejs": "2.3.6",
"rollup": "1.20.3",
"terser": "4.3.1",
"typescript": "^3.3.1"
Expand Down
17 changes: 0 additions & 17 deletions examples/web_testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,6 @@ karma_web_test_suite(
],
)

karma_web_test_suite(
name = "sauce_test",
browsers = [
"@io_bazel_rules_webtesting//browsers/sauce:chrome-win10",
],
tags = [
"exclusive",
"native",
"sauce",
# TODO(alexeagle): enable on CI once we have set the SAUCE env variables
"manual",
],
deps = [
":tests",
],
)

# Just a dummy test so that we have a test target for //... on certain bazelci platforms with bazel_integration_test
sh_test(
name = "dummy_test",
Expand Down
7 changes: 7 additions & 0 deletions examples/web_testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
"@bazel/typescript": "^0.40.0",
"@types/jasmine": "2.8.2",
"@types/node": "11.11.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "2.0.1",
"karma-json-result-reporter": "1.0.0",
"karma-requirejs": "1.1.0",
"karma-sourcemap-loader": "0.3.7",
"requirejs": "2.3.6",
"typescript": "^3.3.1"
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "2.0.1",
"karma-requirejs": "1.1.0",
"karma-sauce-launcher": "2.0.2",
"karma-sourcemap-loader": "0.3.7",
"minimist": "^1.2.0",
"node_resolve_index": "file:./tools/npm_packages/node_resolve_index",
Expand Down
13 changes: 0 additions & 13 deletions packages/karma/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# The generated `@bazel/karma` npm package contains a trimmed BUILD file using INTERNAL fences.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "js_library")
load("@npm_bazel_typescript//:index.from_src.bzl", "ts_library")

package(default_visibility = ["//visibility:public"])
Expand All @@ -43,7 +42,6 @@ nodejs_binary(
"@npm//karma-firefox-launcher",
"@npm//karma-jasmine",
"@npm//karma-requirejs",
"@npm//karma-sauce-launcher",
"@npm//karma-sourcemap-loader",
"@npm//requirejs",
"@npm//tmp",
Expand Down Expand Up @@ -71,23 +69,12 @@ filegroup(
"browser_repositories.bzl",
"index.bzl",
"karma.conf.js",
"karma.js",
"karma_web_test.bzl",
"package.bzl",
"package.json",
"plugins.js",
],
)

js_library(
name = "karma_plugins",
srcs = [
"plugins.js",
],
module_name = "@bazel/karma/plugins",
module_root = "plugins.js",
)

# END-INTERNAL
exports_files([
"karma.conf.js",
Expand Down
23 changes: 16 additions & 7 deletions packages/karma/src/index.from_src.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ load(
_karma_web_test_suite = "karma_web_test_suite",
)

INTERNAL_KARMA_BIN = "@npm_bazel_karma//:karma_bin"
_KARMA_BIN = "@npm_bazel_karma//:karma_bin"
_KARMA_PEER_DEPS = [
"@npm//jasmine-core",
"@npm//karma",
"@npm//karma-chrome-launcher",
"@npm//karma-firefox-launcher",
"@npm//karma-jasmine",
"@npm//karma-requirejs",
"@npm//karma-sourcemap-loader",
"@npm//requirejs",
"@npm//tmp",
]

def karma_web_test(karma = INTERNAL_KARMA_BIN, **kwargs):
data = kwargs.pop("data", []) + ["@npm_bazel_karma//:karma_plugins"]
_karma_web_test(karma = karma, data = data, **kwargs)
def karma_web_test(karma = _KARMA_BIN, **kwargs):
_karma_web_test(karma = karma, peer_deps = _KARMA_PEER_DEPS, **kwargs)

def karma_web_test_suite(karma = INTERNAL_KARMA_BIN, **kwargs):
data = kwargs.pop("data", []) + ["@npm_bazel_karma//:karma_plugins"]
_karma_web_test_suite(karma = karma, data = data, **kwargs)
def karma_web_test_suite(karma = _KARMA_BIN, **kwargs):
_karma_web_test_suite(karma = karma, peer_deps = _KARMA_PEER_DEPS, **kwargs)
57 changes: 9 additions & 48 deletions packages/karma/src/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ try {
function configureBazelConfig(config, conf) {
// list of karma plugins
mergeConfigArray(conf, 'plugins', [
// Loads 'concat_js', 'watcher', 'jasmine', 'requirejs' and 'sourcemap'
// from @bazel/karma. These packages are used in this config file.
...require('@bazel/karma/plugins'),
// Loads 'concat_js'
require('@bazel/karma'),
// Load plugins that are peer deps. These packages are used in this config file.
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-jasmine'),
require('karma-requirejs'),
require('karma-sourcemap-loader'),
// Loads user-installed karma-* packages in the root node_modules.
// If some of the plugins above are also installed in user project, the
// user version would override the default.
'karma-*',
]);

Expand Down Expand Up @@ -307,29 +310,7 @@ try {

const webTestMetadata = require(process.env['WEB_TEST_METADATA']);
log_verbose(`WEB_TEST_METADATA: ${JSON.stringify(webTestMetadata, null, 2)}`);
if (webTestMetadata['environment'] === 'sauce') {
// If a sauce labs browser is chosen for the test such as
// "@io_bazel_rules_webtesting//browsers/sauce:chrome-win10"
// than the 'environment' will equal 'sauce'.
// We expect that a SAUCE_USERNAME and SAUCE_ACCESS_KEY is available
// from the environment for this test to run
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
console.error(
'Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
process.exit(1);
}
// 'capabilities' will specify the sauce labs configuration to use
const capabilities = webTestMetadata['capabilities'];
conf.customLaunchers = {
'sauce': {
base: 'SauceLabs',
browserName: capabilities['browserName'],
platform: capabilities['platform'],
version: capabilities['version'],
}
};
conf.browsers.push('sauce');
} else if (webTestMetadata['environment'] === 'local') {
if (webTestMetadata['environment'] === 'local') {
// When a local chrome or firefox browser is chosen such as
// "@io_bazel_rules_webtesting//browsers:chromium-local" or
// "@io_bazel_rules_webtesting//browsers:firefox-local"
Expand Down Expand Up @@ -376,26 +357,6 @@ try {
if (!conf.browsers.length) {
throw new Error('No browsers configured in web test suite');
}

// Extra configuration is needed for saucelabs
// See: https://github.com/karma-runner/karma-sauce-launcher
if (conf.customLaunchers) {
// set the test name for sauce labs to use
// TEST_BINARY is set by Bazel and contains the name of the test
// target postfixed with the browser name such as
// 'examples/testing/testing_sauce_chrome-win10' for the
// test target examples/testing:testing
if (!conf.sauceLabs) {
conf.sauceLabs = {}
}
conf.sauceLabs.testName = process.env['TEST_BINARY'] || 'karma';

// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
overrideConfigValue(conf, 'transports', ['websocket', 'polling']);

// add the saucelabs reporter
mergeConfigArray(conf, 'reporters', ['saucelabs']);
}
}

function configureTsWebTestConfig(conf) {
Expand Down
3 changes: 0 additions & 3 deletions packages/karma/src/karma.js

This file was deleted.

Loading