angular/packages
Andrew Scott dedac8d3f7 feat(router): Add test helper for trigger navigations in tests (#48552)
In order to test components and services which depend on router navigations, such as `ActivatedRoute` instances, tests currently need to provide a fair bit of boilerplate _or_ they can set up a stub for `ActivatedRoute` and list it in the `providers` to override it in `TestBed`. This approach of stubbing the `ActivatedRoute` creates a situation that can easily cause the test to break. The stub often only mocks out the dependencies that the component/service _currently_ needs. This dependencies might change over time and break the test in an unexpected way. In addition, it is difficult to get the structure of `ActivatedRoute` exactly correct.

This change will allow unit tests to quickly set up routes, trigger real navigations in the Router, and get instances of component's to test along with real instances of `ActivatedRoute`. This all comes without needing to know that the component depends on `ActivatedRoute` at all. This becomes more important when considering that a component may be refactored in the future to use `@Input` rather than access data on the `ActivatedRoute` instance (see #18967). Tests which mock out `ActivatedRoute` would all break, but those which use `navigateForTest` would continue to work without needing any updates.

resolves #15779
resolves #48608

PR Close #48552
2023-01-25 19:31:38 +00:00
..
animations refactor: remove unnecessary test support check utilities (#47543) 2023-01-24 21:06:09 +00:00
bazel refactor(bazel): remove unnecessary banner stamping code (#48798) 2023-01-20 18:39:22 +00:00
benchpress build: ensure bootstrap transitive runfiles are made available (#48521) 2022-12-19 19:50:41 +00:00
common fix(common): warn if using ngSrcset without a configured image loader (#48804) 2023-01-25 19:27:00 +00:00
compiler fix(compiler): incorrect code when non-null assertion is used after a safe access (#48801) 2023-01-25 18:31:37 +00:00
compiler-cli fix(compiler): incorrect code when non-null assertion is used after a safe access (#48801) 2023-01-25 18:31:37 +00:00
core fix(common): warn if using ngSrcset without a configured image loader (#48804) 2023-01-25 19:27:00 +00:00
docs docs: fix packages\docs\di\di.md (#46704) 2022-07-08 17:53:39 +00:00
elements refactor: remove unnecessary test support check utilities (#47543) 2023-01-24 21:06:09 +00:00
examples feat(router): Add test helper for trigger navigations in tests (#48552) 2023-01-25 19:31:38 +00:00
forms refactor(forms): replace type any for the providers (#48647) 2023-01-11 15:01:57 -08:00
language-service refactor(compiler): rework and expose APIs to be used in schematics (#48730) 2023-01-13 12:24:32 -08:00
localize refactor(localize): bundle message digest algorithm directly in npm package (#48799) 2023-01-24 18:31:25 +00:00
misc/angular-in-memory-web-api build: update angular-in-memory-web-api to work with ESM (#48521) 2022-12-19 19:50:42 +00:00
platform-browser refactor: remove unnecessary test support check utilities (#47543) 2023-01-24 21:06:09 +00:00
platform-browser-dynamic refactor: update platform-browser-dynamic to work with ESM output (#48521) 2022-12-19 19:50:43 +00:00
platform-server refactor: update platform-server tests to work with ESM (#48521) 2022-12-19 19:50:43 +00:00
private/testing build: bundle tests for karma web test suites (#48521) 2022-12-19 19:50:42 +00:00
router feat(router): Add test helper for trigger navigations in tests (#48552) 2023-01-25 19:31:38 +00:00
service-worker refactor(service-worker): removing some todos (#48707) 2023-01-24 16:40:23 +00:00
upgrade refactor(upgrade): rewrite the downgrade component adapter (#48715) 2023-01-25 18:32:05 +00:00
zone.js build: update ng-dev and account for stamping changes (#48731) 2023-01-13 14:10:39 +00:00
BUILD.bazel build(bazel): list docs entrypoints under packages to simplify docgen 2022-11-22 13:51:16 -07:00
circular-deps-test.conf.js build: ignore type only imports/exports for circular dependency checks (#47017) 2022-08-18 12:06:09 -07:00
empty.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
goog.d.ts refactor(core): replace references to goog.LOCALE with goog.getLocale() (#43089) 2021-08-10 10:35:26 -07:00
license-banner.txt build: bump license year (#44590) 2022-01-04 12:05:25 -08:00
README.md
system.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tsconfig-build.json refactor: adjust packages/core/test to work with ESM (#48521) 2022-12-19 19:50:42 +00:00
tsconfig-legacy-saucelabs.json refactor: adjust packages/core/test to work with ESM (#48521) 2022-12-19 19:50:42 +00:00
tsconfig-test.json build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
tsconfig-tsec-base.json build: update tsconfigs to use ES2020 as target and module (#43431) 2021-10-01 18:28:42 +00:00
tsconfig.json refactor: adjust packages/core/test to work with ESM (#48521) 2022-12-19 19:50:42 +00:00
tsec-exemption.json fix(core): hardening attribute and property binding rules for <iframe> elements (#47964) 2022-11-09 00:47:56 -08:00
types.d.ts build: update to jasmine 4.0 (#45558) 2022-04-11 16:25:28 +00:00

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT