-
Notifications
You must be signed in to change notification settings - Fork 11.9k
feat(@angular-devkit/build-angular): support karma with application builder #28416
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
Conversation
ff28211
to
587e845
Compare
9428e8c
to
c6d1570
Compare
6839c5c
to
f71e5c8
Compare
f71e5c8
to
63cf55c
Compare
packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/builders/karma/index.ts
Outdated
Show resolved
Hide resolved
b2bc0aa
to
9ef7d75
Compare
In some environments, e.g. containers or in some cases macOS, headless Chrome may not work with the sandbox enabled. This exposes an escape hatch to run tests in those environments. Example use: ```sh yarn bazel test \ //packages/angular_devkit/build_angular:build_angular_karma_test \ --test_env=PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \ --test_env=CHROME_NO_SANDBOX=1 ```
These tests appear to be timing out after 300s somewhat often.
9ef7d75
to
1c15b50
Compare
(削除) Looks like the test projects hadn't been updated for the polyfill change. Added a commit (c21e889) to explicitly add the localize polyfill to them. (削除ここまで) Turns out that this causes issues with the browser builder. Removing the automatic localize injection will be a follow-up item. Ref: #28245
Adds a new "builderMode" setting for Karma that can be used to switch between webpack ("browser") and esbuild ("application"). It supports a third value "detect" that will use the same bundler that's also used for development builds. The detect mode is modelled after the logic used for the dev-server builder. This initial implementation doesn't properly support `--watch` mode or code coverage.
1c15b50
to
40bcfa7
Compare
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
Uh oh!
There was an error while loading. Please reload this page.
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
ng test
for projects that are using Karma has a hard dependency on the webpack builder. Apps can't use application builder features in any files loaded in the tests, really.Issue Number: N/A
What is the new behavior?
Apps can opt into using the application builder by setting the
builderMode
for the karma builder to either "application" or "detect". The latter only works if they switched the app to the new builder for their development/production builds. Once they do, we will use the new application builder toolchain to build their tests before running them in Karma.Does this PR introduce a breaking change?
Other information
This PR builds on top of #28479. The "meat" is in the last commit.
find-tests-plugin.ts
intofind-tests.ts
to ensure we use the same list of test files. The code is otherwise unmodified.karma/index.ts
intokarma/browser_builder.ts
. The code is mostly unmodified though moving out thekarmaOptions
initialization changes the order of operations a bit.--builder-mode=application
without changing a project, even in projects that have akarma.config
file.transforms.webpackConfiguration
is present. This could be made a hard error in the future.--watch
nor--code-coverage
. They are likely both necessary to be a full replacement for many teams. I'm planning to implement at least code coverage in a quick-ish follow-up PR.