Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Conversation

@gregmagolan
Copy link
Contributor

@gregmagolan gregmagolan commented Dec 19, 2018

Adds karma_web_test and karma_web_test_suite which accepts a user base karma configuration in config_file attribute. ts_web_test (a generic web_test rule) uses karma_web_test code under the hood but does not accept a karma configuration. Updated examples/testing:testing to also show karm_web_test usage.

Also some general cleanup in the karma rule.

Prerequisite for angular/angular#27721.

Copy link
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have the user supply a karma plugin rather than a karma conf? Then we don't have the problem that they provide karma settings that conflict with ours under bazel, requiring warnings like we do for tsconfig overrides or similar

rollup_bundle already allows plugins

@gregmagolan
Copy link
Contributor Author

gregmagolan commented Dec 19, 2018

Added configuration_env_vars as well so I could make the following work in angular/angular:

$ yarn bazel test //:test_web_all --define=TS_WEB_TEST_MODE=SL_REQUIRED

karma-js.conf.js:

  switch (process.env.TS_WEB_TEST_MODE) {
    case 'SL_REQUIRED':
      conf.browsers = browserProvidersConf.sauceAliases.CI_REQUIRED;
      break;
    case 'SL_OPTIONAL':
      conf.browsers = browserProvidersConf.sauceAliases.CI_OPTIONAL;
      break;
    case 'BS_REQUIRED':
      conf.browsers = browserProvidersConf.browserstackAliases.CI_REQUIRED;
      break;
    case 'BS_OPTIONAL':
      conf.browsers = browserProvidersConf.browserstackAliases.CI_OPTIONAL;
      break;
    default:
      conf.browsers = [process.env['DISPLAY'] ? 'Chrome' : 'ChromeHeadless'];
  }

Test target of SauceLabs, BrowserStack or local chrome controlled by -define=TS_WEB_TEST_MODE=

@gregmagolan
Copy link
Contributor Author

That's a good question. The plugin would have to be able to be able to override configuration values such as browsers, customLaunchers,sauceLabs, browserStack etc... (see https://github.com/angular/angular/pull/27721/files#diff-c4667ceccd7e91092048e752850fab9c) which would make it functionally the same as a base configuration except harder to setup for users.

@gregmagolan gregmagolan changed the title Support karma base configuration Add karma_web_test and karma_web_test_suite Dec 20, 2018
Copy link
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you already tried to reduce the duplication?

The approach looks good to me, I'll let @kyliau review the karma-specific bits

_ts_web_test_suite = "ts_web_test_suite",
)
load(
"//internal/karma:karma_web_test.bzl",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we should put this in the public API yet.

I think generally we should have some process for maturing new rules before they go in the public API

Copy link
Contributor

@kyliau kyliau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kyliau kyliau closed this in 3ce148a Jan 12, 2019
devversion added a commit to devversion/material2 that referenced this pull request Aug 19, 2019
Switches all `ts_web_test_suite` targets to the new
`karma_web_test_suite` rule. `ts_web_test_suite` is
based on the `karma_web_test_suite` rule but does not
allow developers to have a custom karma configuration.

In order to be able to provide a custom karma configuration
for setting up Saucelabs and Browserstack, we switch all
targets over to the `karma_web_test_suite` rule.

See: bazelbuild/rules_typescript#363.
devversion added a commit to devversion/material2 that referenced this pull request Aug 19, 2019
Switches all `ts_web_test_suite` targets to the new
`karma_web_test_suite` rule. `ts_web_test_suite` is
based on the `karma_web_test_suite` rule but does not
allow developers to have a custom karma configuration.

In order to be able to provide a custom karma configuration
for setting up Saucelabs and Browserstack, we switch all
targets over to the `karma_web_test_suite` rule.

See: bazelbuild/rules_typescript#363.
devversion added a commit to devversion/material2 that referenced this pull request Aug 20, 2019
Switches all `ts_web_test_suite` targets to the new
`karma_web_test_suite` rule. `ts_web_test_suite` is
based on the `karma_web_test_suite` rule but does not
allow developers to have a custom karma configuration.

In order to be able to provide a custom karma configuration
for setting up Saucelabs and Browserstack, we switch all
targets over to the `karma_web_test_suite` rule.

See: bazelbuild/rules_typescript#363.
devversion added a commit to devversion/material2 that referenced this pull request Aug 20, 2019
Switches all `ts_web_test_suite` targets to the new
`karma_web_test_suite` rule. `ts_web_test_suite` is
based on the `karma_web_test_suite` rule but does not
allow developers to have a custom karma configuration.

In order to be able to provide a custom karma configuration
for setting up Saucelabs and Browserstack, we switch all
targets over to the `karma_web_test_suite` rule.

See: bazelbuild/rules_typescript#363.
jelbourn pushed a commit to angular/components that referenced this pull request Aug 20, 2019
Switches all `ts_web_test_suite` targets to the new
`karma_web_test_suite` rule. `ts_web_test_suite` is
based on the `karma_web_test_suite` rule but does not
allow developers to have a custom karma configuration.

In order to be able to provide a custom karma configuration
for setting up Saucelabs and Browserstack, we switch all
targets over to the `karma_web_test_suite` rule.

See: bazelbuild/rules_typescript#363.
andrewseguin pushed a commit to angular/components that referenced this pull request Aug 26, 2019
Switches all `ts_web_test_suite` targets to the new
`karma_web_test_suite` rule. `ts_web_test_suite` is
based on the `karma_web_test_suite` rule but does not
allow developers to have a custom karma configuration.

In order to be able to provide a custom karma configuration
for setting up Saucelabs and Browserstack, we switch all
targets over to the `karma_web_test_suite` rule.

See: bazelbuild/rules_typescript#363.
(cherry picked from commit c791926)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants