W3cubDocs

/Angular

MockLocationStrategy

A mock implementation of LocationStrategy that allows tests to fire simulated location events.

API

class MockLocationStrategy extends LocationStrategy {
  internalBaseHref: string;
  internalPath: string;
  internalTitle: string;
  urlChanges: string[];
  simulatePopState(url: string): void;
  path(includeHash?: boolean): string;
  prepareExternalUrl(internal: string): string;
  pushState(ctx: any, title: string, path: string, query: string): void;
  replaceState(ctx: any, title: string, path: string, query: string): void;
  onPopState(fn: (value: any) => void): void;
  getBaseHref(): string;
  back(): void;
  forward(): void;
  getState(): unknown;
  optional override historyGo(relativePosition: number): void;
}

internalBaseHref

string

internalPath

string

internalTitle

string

urlChanges

string[]

simulatePopState

void
@paramurlstring
@returnsvoid

path

string
@paramincludeHashboolean
@returnsstring

prepareExternalUrl

string
@paraminternalstring
@returnsstring

pushState

void
@paramctxany
@paramtitlestring
@parampathstring
@paramquerystring
@returnsvoid

replaceState

void
@paramctxany
@paramtitlestring
@parampathstring
@paramquerystring
@returnsvoid

onPopState

void
@paramfn(value: any) => void
@returnsvoid

getBaseHref

string
@returnsstring

back

void
@returnsvoid

forward

void
@returnsvoid

getState

unknown
@returnsunknown

historyGo

void
@paramrelativePositionnumber
@returnsvoid

Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/api/common/testing/MockLocationStrategy