diff --git a/packages/common/test/directives/ng_for_spec.ts b/packages/common/test/directives/ng_for_spec.ts index 2b09e4cb331..0986b5e5c06 100644 --- a/packages/common/test/directives/ng_for_spec.ts +++ b/packages/common/test/directives/ng_for_spec.ts @@ -119,7 +119,7 @@ describe('ngFor', () => { getComponent().items = 'whaaa'; expect(() => fixture.detectChanges()).toThrowError( - `NG02200: Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables, such as Arrays. Find more at https://angular.dev/errors/NG02200`, + /NG02200: Cannot find a differ supporting object 'whaaa' of type 'string'\. NgFor only supports binding to Iterables, such as Arrays\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG02200/, ); })); @@ -128,7 +128,7 @@ describe('ngFor', () => { getComponent().items = {'stuff': 'whaaa'}; expect(() => fixture.detectChanges()).toThrowError( - `NG02200: Cannot find a differ supporting object '\[object Object\]' of type 'object'. NgFor only supports binding to Iterables, such as Arrays. Did you mean to use the keyvalue pipe? Find more at https://angular.dev/errors/NG02200`, + /NG02200: Cannot find a differ supporting object '\[object Object\]' of type 'object'\. NgFor only supports binding to Iterables, such as Arrays\. Did you mean to use the keyvalue pipe\? Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG02200/, ); })); diff --git a/packages/core/src/error_details_base_url.ts b/packages/core/src/error_details_base_url.ts index 8cc9e5fa701..673039aa994 100644 --- a/packages/core/src/error_details_base_url.ts +++ b/packages/core/src/error_details_base_url.ts @@ -8,6 +8,17 @@ import {VERSION} from './version'; +export const DOC_PAGE_BASE_URL: string = (() => { + const full = VERSION.full; + const isPreRelease = + full.includes('-next') || + full.includes('-rc') || + // Avoid direct literal to prevent build stamping replacement + full === '0.0.0' + '-PLACEHOLDER'; + const prefix = isPreRelease ? 'next' : `v${VERSION.major}`; + return `https://${prefix}.angular.dev`; +})(); + /** * Base URL for the error details page. * @@ -16,10 +27,8 @@ import {VERSION} from './version'; * - packages/core/src/error_details_base_url.ts */ export const ERROR_DETAILS_PAGE_BASE_URL: string = (() => { - const versionSubDomain = VERSION.major !== '0' ? `v${VERSION.major}.` : ''; - return `https://${versionSubDomain}angular.dev/errors`; + return `${DOC_PAGE_BASE_URL}/errors`; })(); - /** * URL for the XSS security documentation. */ diff --git a/packages/core/src/hydration/api.ts b/packages/core/src/hydration/api.ts index 71a800e4211..e6272d6eae4 100644 --- a/packages/core/src/hydration/api.ts +++ b/packages/core/src/hydration/api.ts @@ -56,6 +56,7 @@ import {DEHYDRATED_BLOCK_REGISTRY, DehydratedBlockRegistry} from '../defer/regis import {gatherDeferBlocksCommentNodes} from './node_lookup_utils'; import {processAndInitTriggers} from '../defer/triggering'; import {DOCUMENT} from '../document'; +import {DOC_PAGE_BASE_URL} from '../error_details_base_url'; /** * Indicates whether the hydration-related code was added, @@ -148,7 +149,7 @@ function printHydrationStats(injector: Injector) { (isIncrementalHydrationEnabled(injector) ? `${ngDevMode!.deferBlocksWithIncrementalHydration} defer block(s) were configured to use incremental hydration. ` : '') + - `Learn more at https://angular.dev/guide/hydration.`; + `Learn more at ${DOC_PAGE_BASE_URL}/guide/hydration.`; // tslint:disable-next-line:no-console console.log(message); } diff --git a/packages/core/src/image_performance_warning.ts b/packages/core/src/image_performance_warning.ts index b99d6347a7d..e9c3afb583e 100644 --- a/packages/core/src/image_performance_warning.ts +++ b/packages/core/src/image_performance_warning.ts @@ -12,6 +12,7 @@ import {inject} from './di/injector_compatibility'; import {formatRuntimeError, RuntimeErrorCode} from './errors'; import {OnDestroy} from './change_detection/lifecycle_hooks'; import {getDocument} from './render3/interfaces/document'; +import {ERROR_DETAILS_PAGE_BASE_URL} from './error_details_base_url'; // A delay in milliseconds before the scan is run after onLoad, to avoid any // potential race conditions with other LCP-related functions. This delay @@ -213,7 +214,7 @@ function logLazyLCPWarning(src: string) { `changing the loading value of the LCP image to "eager", or by using the ` + `NgOptimizedImage directive's prioritization utilities. For more ` + `information about addressing or disabling this warning, see ` + - `https://angular.dev/errors/NG0913`, + `${ERROR_DETAILS_PAGE_BASE_URL}/NG0913`, ), ); } @@ -225,7 +226,7 @@ function logOversizedImageWarning(src: string) { `An image with src ${src} has intrinsic file dimensions much larger than its ` + `rendered size. This can negatively impact application loading performance. ` + `For more information about addressing or disabling this warning, see ` + - `https://angular.dev/errors/NG0913`, + `${ERROR_DETAILS_PAGE_BASE_URL}/NG0913`, ), ); } diff --git a/packages/core/test/acceptance/di_forward_ref_spec.ts b/packages/core/test/acceptance/di_forward_ref_spec.ts index dd4bb850eb8..fd3cfb482b9 100644 --- a/packages/core/test/acceptance/di_forward_ref_spec.ts +++ b/packages/core/test/acceptance/di_forward_ref_spec.ts @@ -8,6 +8,7 @@ import {Component, Directive, forwardRef, Host, Inject, ViewChild} from '@angular/core'; import {TestBed} from '../../testing'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; // **NOTE**: More details on why tests relying on `forwardRef` are put into this // file can be found in the `BUILD.bazel` file declaring the forward ref test target. @@ -41,7 +42,7 @@ describe('di with forwardRef', () => { expect(() => TestBed.createComponent(MyComp)).toThrowError( 'NG0200: Circular dependency detected for `DirectiveA`. ' + 'Path: DirectiveA -> DirectiveB -> DirectiveA. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); diff --git a/packages/core/test/acceptance/di_spec.ts b/packages/core/test/acceptance/di_spec.ts index c081611ff80..fa19c69b477 100644 --- a/packages/core/test/acceptance/di_spec.ts +++ b/packages/core/test/acceptance/di_spec.ts @@ -62,6 +62,7 @@ import { DestroyRef, provideZoneChangeDetection, } from '../../src/core'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; import {RuntimeError, RuntimeErrorCode} from '../../src/errors'; import {ViewRef as ViewRefInternal} from '../../src/render3/view_ref'; import {TestBed} from '../../testing'; @@ -1263,7 +1264,7 @@ describe('di', () => { expect(() => TestBed.createComponent(MyComp)).toThrowError( 'NG0200: Circular dependency detected for `DirectiveA`. ' + 'Path: DirectiveA -> DirectiveA. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -2553,7 +2554,7 @@ describe('di', () => { TestBed.configureTestingModule({declarations: [DirectiveString, MyComp, MyApp]}); expect(() => TestBed.createComponent(MyApp)).toThrowError( - 'NG0201: No provider for String found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for String found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); @@ -2651,7 +2652,7 @@ describe('di', () => { TestBed.configureTestingModule({declarations: [DirectiveComp, MyComp, MyApp]}); expect(() => TestBed.createComponent(MyApp)).toThrowError( - 'NG0201: No provider for MyApp found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for MyApp found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); @@ -6640,7 +6641,7 @@ describe('di', () => { 'NG0200: Circular dependency detected for `InjectionToken A`. ' + 'Source: DynamicTestModule. ' + 'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -6676,7 +6677,7 @@ describe('di', () => { 'NG0200: Circular dependency detected for `InjectionToken A`. ' + 'Source: DynamicTestModule. ' + 'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -6719,7 +6720,7 @@ describe('di', () => { 'NG0200: Circular dependency detected for `InjectionToken A`. ' + 'Source: DynamicTestModule. ' + 'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -6737,7 +6738,7 @@ describe('di', () => { expect(() => createInjector(AModule)).toThrowError( 'NG0200: Circular dependency detected for `AModule`. ' + 'Path: AModule -> BModule -> AModule. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -6781,7 +6782,7 @@ describe('di', () => { 'NG0200: Circular dependency detected for `InjectionToken A`. ' + 'Source: DynamicTestModule. ' + 'Path: InjectionToken A -> InjectionToken B -> InjectionToken A. ' + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -6818,7 +6819,7 @@ describe('di', () => { expect(() => TestBed.createComponent(App)).toThrowError( 'NG0200: Circular dependency detected for `InjectionToken A`. ' + "Path: App -> ('InjectionToken A':AService) -> ('InjectionToken B':BService) -> ('InjectionToken A':AService). " + - 'Find more at https://angular.dev/errors/NG0200', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); }); diff --git a/packages/core/test/application_init_spec.ts b/packages/core/test/application_init_spec.ts index 7bb46972e3a..146c2f6a9d2 100644 --- a/packages/core/test/application_init_spec.ts +++ b/packages/core/test/application_init_spec.ts @@ -13,6 +13,7 @@ import { InjectionToken, provideAppInitializer, } from '../src/core'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../src/error_details_base_url'; import {EMPTY, Observable, Subscriber} from 'rxjs'; import {TestBed} from '../testing'; @@ -187,7 +188,7 @@ describe('ApplicationInitStatus', () => { 'NG0209: Unexpected type of the `APP_INITIALIZER` token value ' + `(expected an array, but got string). ` + 'Please check that the `APP_INITIALIZER` token is configured as a ' + - '`multi: true` provider. Find more at https://angular.dev/errors/NG0209', + `\`multi: true\` provider. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0209`, ); }); }); diff --git a/packages/core/test/application_ref_spec.ts b/packages/core/test/application_ref_spec.ts index 6b54b8fa0e0..3c70a175602 100644 --- a/packages/core/test/application_ref_spec.ts +++ b/packages/core/test/application_ref_spec.ts @@ -13,6 +13,7 @@ import { ɵDomRendererFactory2 as DomRendererFactory2, } from '@angular/platform-browser'; import type {ServerModule} from '@angular/platform-server'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../src/error_details_base_url'; import {createTemplate, dispatchEvent, getContent, isNode} from '@angular/private/testing'; import {expect} from '@angular/private/testing/matchers'; import { @@ -586,7 +587,7 @@ describe('bootstrap', () => { `NG0403: The module MyModule was bootstrapped, ` + `but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` + `Please define one of these. ` + - `Find more at https://angular.dev/errors/NG0403`; + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0403`; expect(e.message).toEqual(expectedErrMsg); expect(mockConsole.res[0].join('#')).toEqual('ERROR#Error: ' + expectedErrMsg); }, diff --git a/packages/core/test/di/injector_spec.ts b/packages/core/test/di/injector_spec.ts index 8b7fbb9f2b6..75a7d01bf40 100644 --- a/packages/core/test/di/injector_spec.ts +++ b/packages/core/test/di/injector_spec.ts @@ -7,19 +7,20 @@ */ import {Injector} from '../../src/core'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; describe('Injector.NULL', () => { it('should throw if no arg is given', () => { expect(() => Injector.NULL.get('someToken')).toThrowError( 'NG0201: No provider found for `someToken`. ' + - 'Find more at https://angular.dev/errors/NG0201', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); it('should throw if THROW_IF_NOT_FOUND is given', () => { expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND)).toThrowError( 'NG0201: No provider found for `someToken`. ' + - 'Find more at https://angular.dev/errors/NG0201', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); diff --git a/packages/core/test/di/r3_injector_spec.ts b/packages/core/test/di/r3_injector_spec.ts index 89c0c1eea79..c1aba322548 100644 --- a/packages/core/test/di/r3_injector_spec.ts +++ b/packages/core/test/di/r3_injector_spec.ts @@ -15,6 +15,7 @@ import { ɵɵdefineInjector, ɵɵinject, } from '../../src/core'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; import {createInjector} from '../../src/di/create_injector'; import {InternalInjectFlags} from '../../src/di/interface/injector'; import {R3Injector} from '../../src/di/r3_injector'; @@ -339,7 +340,7 @@ describe('InjectorDef-based createInjector()', () => { expect(() => injector.get(ServiceTwo)).toThrowError( 'NG0201: No provider found for `ServiceTwo`. ' + 'Source: Module. ' + - 'Find more at https://angular.dev/errors/NG0201', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); @@ -347,7 +348,7 @@ describe('InjectorDef-based createInjector()', () => { const injector = createInjector([ServiceTwo]); expect(() => injector.get(ServiceTwo)).toThrowError( 'NG0201: No provider found for `ServiceTwo`. ' + - 'Find more at https://angular.dev/errors/NG0201', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); @@ -357,7 +358,7 @@ describe('InjectorDef-based createInjector()', () => { 'NG0201: No provider found for `Service`. ' + 'Source: ModuleWithMissingDep. ' + 'Path: ServiceWithMissingDep -> Service. ' + - 'Find more at https://angular.dev/errors/NG0201', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); diff --git a/packages/core/test/di/static_injector_spec.ts b/packages/core/test/di/static_injector_spec.ts index 6656fe43149..c7364f93006 100644 --- a/packages/core/test/di/static_injector_spec.ts +++ b/packages/core/test/di/static_injector_spec.ts @@ -7,6 +7,7 @@ */ import {forwardRef, Inject, Injector, Self, SkipSelf} from '../../src/core'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; import {stringify} from '../../src/util/stringify'; @@ -106,7 +107,7 @@ describe('dependency resolution', () => { expect(() => child.get(Car)).toThrowError( 'NG0201: No provider found for `Engine`. ' + 'Path: Car -> Engine. ' + - 'Find more at https://angular.dev/errors/NG0201', + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); @@ -131,7 +132,8 @@ describe('dependency resolution', () => { it('should throw error when not requested provider on self', () => { const injector = Injector.create({providers: []}); expect(() => injector.get(Car, undefined, {self: true})).toThrowError( - 'NG0201: No provider found for `Car`. ' + 'Find more at https://angular.dev/errors/NG0201', + 'NG0201: No provider found for `Car`. ' + + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); }); diff --git a/packages/core/test/linker/ng_module_integration_spec.ts b/packages/core/test/linker/ng_module_integration_spec.ts index 37d68710097..5680166765b 100644 --- a/packages/core/test/linker/ng_module_integration_spec.ts +++ b/packages/core/test/linker/ng_module_integration_spec.ts @@ -39,6 +39,7 @@ import { setAllowDuplicateNgModuleIdsForTest, } from '../../src/linker/ng_module_registration'; import {stringify} from '../../src/util/stringify'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; class Engine {} @@ -625,7 +626,7 @@ describe('NgModule', () => { const errorMsg = 'NG0201: No provider found for `SportsCar`. ' + 'Source: SomeModule. Path: car -> SportsCar. ' + - 'Find more at https://angular.dev/errors/NG0201'; + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`; expect(() => injector.get('car')).toThrowError(errorMsg); }); @@ -831,7 +832,7 @@ describe('NgModule', () => { const errorMsg = 'NG0201: No provider found for `NonExisting`. ' + 'Source: SomeModule. ' + - 'Find more at https://angular.dev/errors/NG0201'; + `Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`; expect(() => injector.get('NonExisting')).toThrowError(errorMsg); }); @@ -839,7 +840,7 @@ describe('NgModule', () => { expect(() => createInjector([Car, {provide: Engine, useClass: CyclicEngine}]).get(Car), ).toThrowError( - 'NG0200: Circular dependency detected for `Car`. Source: SomeModule. Path: Car -> Engine -> Car. Find more at https://angular.dev/errors/NG0200', + `NG0200: Circular dependency detected for \`Car\`. Source: SomeModule. Path: Car -> Engine -> Car. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); diff --git a/packages/core/test/linker/view_injector_integration_spec.ts b/packages/core/test/linker/view_injector_integration_spec.ts index 39310b87fe3..849244dc1ee 100644 --- a/packages/core/test/linker/view_injector_integration_spec.ts +++ b/packages/core/test/linker/view_injector_integration_spec.ts @@ -36,6 +36,7 @@ import { } from '../../src/core'; import {ComponentFixture, fakeAsync, TestBed} from '../../testing'; import {expect} from '@angular/private/testing/matchers'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; @Directive({ selector: '[simpleDirective]', @@ -769,7 +770,7 @@ describe('View injector', () => { it('should not instantiate a directive with cyclic dependencies', () => { TestBed.configureTestingModule({declarations: [CycleDirective]}); expect(() => createComponent('
')).toThrowError( - 'NG0200: Circular dependency detected for `CycleDirective`. Path: CycleDirective -> CycleDirective. Find more at https://angular.dev/errors/NG0200', + `NG0200: Circular dependency detected for \`CycleDirective\`. Path: CycleDirective -> CycleDirective. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0200`, ); }); @@ -786,7 +787,7 @@ describe('View injector', () => { }); expect(() => createComponent('
')).toThrowError( - 'NG0201: No provider for service found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for service found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }, ); @@ -808,7 +809,7 @@ describe('View injector', () => { expect(() => createComponent('
'), ).toThrowError( - 'NG0201: No provider for service found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for service found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }, ); @@ -818,7 +819,7 @@ describe('View injector', () => { expect(() => createComponent('
'), ).toThrowError( - 'NG0201: No provider for SimpleDirective found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for SimpleDirective found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); @@ -864,7 +865,7 @@ describe('View injector', () => { set: {template: '
'}, }); expect(() => createComponent('
')).toThrowError( - 'NG0201: No provider for SimpleDirective found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for SimpleDirective found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); diff --git a/packages/core/test/render3/di_spec.ts b/packages/core/test/render3/di_spec.ts index 167c9a34291..0f2b6ed873f 100644 --- a/packages/core/test/render3/di_spec.ts +++ b/packages/core/test/render3/di_spec.ts @@ -9,6 +9,7 @@ import {Component, Directive, Self} from '../../src/core'; import {NodeInjectorOffset} from '../../src/render3/interfaces/injector'; import {TestBed} from '../../testing'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../../src/error_details_base_url'; import { bloomAdd, @@ -46,7 +47,7 @@ describe('di', () => { expect(() => { TestBed.createComponent(App).detectChanges(); }).toThrowError( - 'NG0201: No provider for DirNotOnSelf found in NodeInjector. Find more at https://angular.dev/errors/NG0201', + `NG0201: No provider for DirNotOnSelf found in NodeInjector. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0201`, ); }); }); diff --git a/packages/core/test/runtime_error_spec.ts b/packages/core/test/runtime_error_spec.ts index e0d6406b933..74bcbc32988 100644 --- a/packages/core/test/runtime_error_spec.ts +++ b/packages/core/test/runtime_error_spec.ts @@ -7,11 +7,14 @@ */ import {RuntimeError, RuntimeErrorCode} from '../src/errors'; +import {ERROR_DETAILS_PAGE_BASE_URL} from '../src/error_details_base_url'; describe('RuntimeError utils', () => { it('should correctly format an error without an error message', () => { const error = new RuntimeError(RuntimeErrorCode.EXPORT_NOT_FOUND, ''); - expect(error.toString()).toBe('Error: NG0301. Find more at https://angular.dev/errors/NG0301'); + expect(error.toString()).toBe( + `Error: NG0301. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0301`, + ); }); it('should correctly format an error without an error message not adev guide', () => { @@ -27,7 +30,7 @@ describe('RuntimeError utils', () => { it('should correctly format an error with both an error message and an adev guide', () => { const error = new RuntimeError(RuntimeErrorCode.EXPORT_NOT_FOUND, 'Some error message'); expect(error.toString()).toBe( - 'Error: NG0301: Some error message. Find more at https://angular.dev/errors/NG0301', + `Error: NG0301: Some error message. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0301`, ); }); @@ -39,7 +42,7 @@ describe('RuntimeError utils', () => { errorMessage, ); expect(error.toString()).toBe( - `Error: NG0302: Pipe not found${character} Find more at https://angular.dev/errors/NG0302`, + `Error: NG0302: Pipe not found${character} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0302`, ); }), ); diff --git a/packages/forms/test/directives_spec.ts b/packages/forms/test/directives_spec.ts index dd43eb2bd78..b1958af6ddf 100644 --- a/packages/forms/test/directives_spec.ts +++ b/packages/forms/test/directives_spec.ts @@ -229,9 +229,7 @@ describe('Form Directives', () => { dir.name = 'login'; expect(() => form.addControl(dir)).toThrowError( - new RegExp( - `NG01203: No value accessor for form control name: 'login'. Find more at https://angular.dev/errors/NG01203`, - ), + /NG01203: No value accessor for form control name: 'login'\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG01203/, ); }); @@ -242,9 +240,7 @@ describe('Form Directives', () => { dir.name = 'password'; expect(() => form.addControl(dir)).toThrowError( - new RegExp( - `NG01203: No value accessor for form control path: 'passwords -> password'. Find more at https://angular.dev/errors/NG01203`, - ), + /NG01203: No value accessor for form control path: 'passwords -> password'\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG01203/, ); }); @@ -668,9 +664,7 @@ describe('Form Directives', () => { namedDir.name = 'one'; expect(() => namedDir.ngOnChanges({})).toThrowError( - new RegExp( - `NG01203: No value accessor for form control name: 'one'. Find more at https://angular.dev/errors/NG01203`, - ), + /NG01203: No value accessor for form control name: 'one'\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG01203/, ); }); @@ -678,9 +672,7 @@ describe('Form Directives', () => { const unnamedDir = new NgModel(null!, null!, null!, null!); expect(() => unnamedDir.ngOnChanges({})).toThrowError( - new RegExp( - `NG01203: No value accessor for form control unspecified name attribute. Find more at https://angular.dev/errors/NG01203`, - ), + /NG01203: No value accessor for form control unspecified name attribute\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG01203/, ); }); diff --git a/packages/forms/test/form_control_spec.ts b/packages/forms/test/form_control_spec.ts index 74e976cf052..06e9ecdbdb8 100644 --- a/packages/forms/test/form_control_spec.ts +++ b/packages/forms/test/form_control_spec.ts @@ -1538,9 +1538,7 @@ import {asyncValidator, asyncValidatorReturningObservable} from './util'; // but // not a meaningful one expect(fn).toThrowError( - 'NG01101: Expected async validator to return Promise or Observable. ' + - 'Are you using a synchronous validator where an async validator is expected? ' + - 'Find more at https://angular.dev/errors/NG01101', + /NG01101: Expected async validator to return Promise or Observable\. Are you using a synchronous validator where an async validator is expected\? Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG01101/, ); }); diff --git a/packages/forms/test/reactive_integration_spec.ts b/packages/forms/test/reactive_integration_spec.ts index bcacf0e43db..20aa276a03c 100644 --- a/packages/forms/test/reactive_integration_spec.ts +++ b/packages/forms/test/reactive_integration_spec.ts @@ -6042,7 +6042,7 @@ describe('reactive forms integration tests', () => { expect(() => { fixture.detectChanges(); }).toThrowError( - `NG01203: No value accessor for form control name: 'control'. Find more at https://angular.dev/errors/NG01203`, + /NG01203: No value accessor for form control name: 'control'\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG01203/, ); // Making sure that cleanup between tests doesn't cause any issues diff --git a/packages/platform-browser/test/browser/bootstrap_standalone_spec.ts b/packages/platform-browser/test/browser/bootstrap_standalone_spec.ts index 9ab39fc65e3..29fb96a361d 100644 --- a/packages/platform-browser/test/browser/bootstrap_standalone_spec.ts +++ b/packages/platform-browser/test/browser/bootstrap_standalone_spec.ts @@ -130,11 +130,8 @@ describe('bootstrapApplication for standalone components', () => { fail('Expected to throw'); } catch (e: unknown) { expect(e).toBeInstanceOf(Error); - expect((e as Error).message).toContain( - 'NG0201: No provider found for `InjectionToken ambient token`. ' + - 'Source: Standalone[StandaloneCmp]. ' + - 'Path: NeedsAmbientProvider -> InjectionToken ambient token. ' + - 'Find more at https://angular.dev/errors/NG0201', + expect((e as Error).message).toMatch( + /NG0201: No provider found for `InjectionToken ambient token`\. Source: Standalone\[StandaloneCmp\]\. Path: NeedsAmbientProvider -> InjectionToken ambient token\. Find more at https:\/\/(?:next\.)?angular\.dev\/errors\/NG0201/, ); } }),