projects/ng-magic-test-bed/src/setup-test-bed/ng-magic-setup-test-bed.class.ts
Methods |
|
| Public componentMocks | ||||||||
componentMocks(componentClass: Type
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:267
|
||||||||
Type parameters :
|
||||||||
|
declare that you want to generically mock all inputs and outputs of a component and retrieve all created component mock instances after fixture creation.
Parameters :
Returns :
Array<C>
an array of all component instances that were found statically inside the fixture. The array's members can only be used after calling .fixture(). Before that time the array is initialized like this: ['this array can only be used after fixture() was called']. |
| Public componentProviderMock | ||||||||||||||||||||||||||||||
componentProviderMock(componentClass: Type
|
||||||||||||||||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||||||||||||||||
|
Defined in
NgMagicTestBed:193
|
||||||||||||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||||||||||||
|
If you have component provides a provider you can mock it using this method.
Parameters :
Returns :
|
|
| Public componentServiceMock | |||||||||||||||
componentServiceMock(componentClass: Type
|
|||||||||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||||||||
|
Defined in
NgMagicTestBed:167
|
|||||||||||||||
Type parameters :
|
|||||||||||||||
|
Parameters :
|
| Public componentServiceMock | ||||||||||||
componentServiceMock(componentClass: Type
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:169
|
||||||||||||
Type parameters :
|
||||||||||||
|
Parameters :
|
| Public componentServiceMock | |||||||||
componentServiceMock(componentClass: Type
|
|||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||
|
Defined in
NgMagicTestBed:171
|
|||||||||
Type parameters :
|
|||||||||
|
Parameters :
Returns :
SpyObj<S>
|
| Public componentServiceMock | ||||||||||||||||||||
componentServiceMock(componentClass: Type
|
||||||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||||||
|
Defined in
NgMagicTestBed:180
|
||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||
|
If you have component that provides a service you can mock it using this method.
Parameters :
Returns :
|
|
| Public declaration | ||||||||
declaration(declaration: any)
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:48
|
||||||||
|
Parameters :
Returns :
void
|
| Public declarations | ||||||||
declarations(declarations: Array
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:37
|
||||||||
|
Parameters :
Returns :
void
|
| Public directiveMocks | ||||||||
directiveMocks(directiveClass: Type
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:209
|
||||||||
Type parameters :
|
||||||||
|
declare that you want to mock a directive for a selector and retrieve all created component mock instances after fixture creation. Note that this method behaves different to directiveMocks. This is because Angular is missing a public reflectDirectiveType method. This method will be made smarter as soon as such a method is available.
Parameters :
Returns :
Array<C>
an array of all component instances that were found statically inside the fixture. The array's members can only be used after calling .fixture(). Before that time the array is initialized like this: ['this array can only be used after fixture() was called']. |
| Public directiveProviderMock | ||||||||||||||||||||||||||||||
directiveProviderMock(directiveClass: Type
|
||||||||||||||||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||||||||||||||||
|
Defined in
NgMagicTestBed:161
|
||||||||||||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||||||||||||
|
If you have directive that provides a provider you can mock it using this method.
Parameters :
Returns :
|
|
| Public directiveServiceMock | ||||||||||||||||||||
directiveServiceMock(directiveClass: Type
|
||||||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||||||
|
Defined in
NgMagicTestBed:142
|
||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||
|
If you have directive that provides a service you can mock it using this method.
Parameters :
|
| Public directiveServiceMock | ||||||||||||
directiveServiceMock(directiveClass: Type
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:144
|
||||||||||||
Type parameters :
|
||||||||||||
|
Parameters :
|
| Public directiveServiceMock | |||||||||
directiveServiceMock(directiveClass: Type
|
|||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||
|
Defined in
NgMagicTestBed:146
|
|||||||||
Type parameters :
|
|||||||||
|
Parameters :
Returns :
SpyObj<S>
|
| Public directiveServiceMock | |||||||||||||||
directiveServiceMock(directiveClass: Type
|
|||||||||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||||||||
|
Defined in
NgMagicTestBed:148
|
|||||||||||||||
Type parameters :
|
|||||||||||||||
|
Parameters :
Returns :
|
|
| Public factoryMock | ||||||||||||
factoryMock(factoryClass: AbstractType
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:356
|
||||||||||||
Type parameters :
|
||||||||||||
|
mocks a service that has a "create" method.
Parameters :
Returns :
SpyObj<F>
a mock for the factory. mock.create will return the one of the given instances every time it is called |
| Public fixture | ||||||||||||||||||||
fixture(componentClass: Type
|
||||||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||||||
|
Defined in
NgMagicTestBed:283
|
||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||
|
Use this method to create a component fixture. This method may only be called once per NgMagicTestBed instance.
Parameters :
Returns :
ComponentFixture<C>
a component fixture like standard TestBed.createComponent(componentClass) would have returned it. |
| Public import | ||||||
import(aImport: any)
|
||||||
|
Inherited from
NgMagicTestBed
|
||||||
|
Defined in
NgMagicTestBed:94
|
||||||
|
Parameters :
Returns :
void
|
| Public imports | ||||||||
imports(imports: any[])
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:83
|
||||||||
|
Parameters :
Returns :
void
|
| Public injection | ||||||||
injection(token: ProviderToken
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:394
|
||||||||
Type parameters :
|
||||||||
|
return you the service or provider for a given token from the angular dependency injection. This will trigger the TestBed configureTestingModule step. After this step you can not create any more mocks. Make sure you create all your mocks before calling this method.
Parameters :
Returns :
S
whatever angular dependency injection finds for your token |
| Public interfaceMock | |||||||||||||||
interfaceMock(mock: I, dontSpy)
|
|||||||||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||||||||
|
Defined in
NgMagicTestBed:317
|
|||||||||||||||
Type parameters :
|
|||||||||||||||
|
Creates a mock object that satisfies the shape of a TypeScript interface I. This does not (and cannot) replace I anywhere - interfaces have no runtime representation, so there is no prototype to reflect on the way objectMock() reflects on a class. This means every member of I has to be supplied in mock - only the methods you actually provide become spies, nothing can be auto-generated for the ones you omit. Use this instead of objectMock(undefined, mock) purely to avoid casting the result to I & SpyObj yourself.
Parameters :
|
| Public keptComponentImports | ||||||||
keptComponentImports(keptComponentImports: Array
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:109
|
||||||||
|
Declare that you want to keep several pipes/directives/standalone components exactly as they are, in one call. Each one is added to the imports (or declarations, for non-standalone classes) of your fixture component and all other kept components - the same effect as calling keptPipe() once per item, but without the per-item boilerplate and without querying for instances afterward. Typical use: keeping Angular's own structural directives/pipes (NgIf, NgFor, AsyncPipe, ...) that your fixture component's template relies on, since overriding a standalone component's imports for fixture/mock purposes replaces its imports array entirely - see keptDirectives()/keptComponents() if you also need access to the rendered instances afterward.
Parameters :
Returns :
void
|
| Public keptComponents | ||||||
keptComponents(componentClass: Type
|
||||||
|
Inherited from
NgMagicTestBed
|
||||||
|
Defined in
NgMagicTestBed:255
|
||||||
Type parameters :
|
||||||
|
Declare that you want to keep a certain component. This kept component will be added to the imports of your fixture component and all other kept components.
Parameters :
Returns :
Array<C>
an array of all component instances that were found statically inside the fixture. The array's members can only be used after calling .fixture(). Before that time the array is initialized like this: ['this array can only be used after fixture() was called']. |
| Public keptDirectives | ||||||
keptDirectives(directiveClass: Type
|
||||||
|
Inherited from
NgMagicTestBed
|
||||||
|
Defined in
NgMagicTestBed:244
|
||||||
Type parameters :
|
||||||
|
Declare that you want to keep a certain directive. This kept directive will be added to the imports of your fixture component and all kept components.
Parameters :
Returns :
Array<C>
|
| Public keptPipe | ||||||||
keptPipe(pipeClass: Type
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:235
|
||||||||
Type parameters :
|
||||||||
|
declare that you want to keep a pipe for a selector.
Parameters :
Returns :
void
|
| Public objectMock | ||||||||||||||||
objectMock(objectClass: AbstractType
|
||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||
|
Defined in
NgMagicTestBed:295
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
|
Can be used to create a mock for an object that should not be registered at angular TestBed.
Parameters :
|
| Public objectMock | |||||||||
objectMock(objectClass: AbstractType
|
|||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||
|
Defined in
NgMagicTestBed:297
|
|||||||||
Type parameters :
|
|||||||||
|
Parameters :
|
| Public objectMock | |||||||||
objectMock(objectClass: undefined, mock: M)
|
|||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||
|
Defined in
NgMagicTestBed:299
|
|||||||||
Type parameters :
|
|||||||||
|
Parameters :
Returns :
SpyObj<M>
|
| Public objectMock | ||||||||||||||||
objectMock(objectClass: AbstractType
|
||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||
|
Defined in
NgMagicTestBed:301
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
|
Parameters :
Returns :
|
|
| Public observer | ||||||||||||
observer(observable: Observable
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:412
|
||||||||||||
Type parameters :
|
||||||||||||
|
Subscribes to a given observable and spies on its states and emitted values.
Parameters :
Returns :
SpyObserver<T>
observer that can be used to make assertions in your test cases e.g.: expect(observer.next).toHaveBeenCalledWith(expectedValue); For more information check SpyObserver documentation |
| Public outputObserver | ||||||||||||
outputObserver(output: OutputEmitterRef
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:429
|
||||||||||||
Type parameters :
|
||||||||||||
|
Subscribes to a given output and spies on its states and emitted values.
Parameters :
Returns :
SpyObserver<T>
outputObserver that can be used to make assertions in your test cases e.g.: expect(outputObserver.next).toHaveBeenCalledWith(expectedValue); For more information check SpyObserver documentation |
| Public pipeMock |
pipeMock(pipeName: string, transform?: (value?: any) => void)
|
|
Inherited from
NgMagicTestBed
|
|
Defined in
NgMagicTestBed:217
|
Type parameters :
|
|
declare that you want to mock a pipe for a selector.
Returns :
Spy
|
| Public provider | ||||||||
provider(provider: any)
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:131
|
||||||||
|
Parameters :
Returns :
void
|
| Public providerFunctionMock | ||||||||||||
providerFunctionMock(token: InjectionToken
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:343
|
||||||||||||
Type parameters :
|
||||||||||||
|
replaces a function that is provided with an angular provider token with a spy
Parameters :
Returns :
Spy<F>
spy on the mocked provider function |
| Public providerMock | |||||||||||||||||||||||||
providerMock(token: ProviderToken
|
|||||||||||||||||||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||||||||||||||||||
|
Defined in
NgMagicTestBed:331
|
|||||||||||||||||||||||||
Type parameters :
|
|||||||||||||||||||||||||
|
mocks a provider for a given token with a given mock. If wanted your mock can be extended by spies from a given spySource class.
Parameters :
Returns :
|
Your mocks methods will be overwritten with spies that call through to the mocks methods like spyOn method of your test framework. In addition to that a spy will be added for each additional method that was found on the objectClass' prototype. |
| Public providers | ||||||||
providers(providers: any[])
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:120
|
||||||||
|
Parameters :
Returns :
void
|
| Public run |
run()
|
|
Inherited from
NgMagicTestBed
|
|
Defined in
NgMagicTestBed:442
|
|
Can be used to run a callback in injection context. Like TestBed.runInInjectionContext(). Additionally this will trigger the TestBed configureTestingModule step. After this step you can not create any more mocks. Make sure you create all your mocks before calling this method. This method can be used to configure the testing module when used without
Returns :
void
what |
| Public run | ||||||
run(callbackToBeRunInInjectionContext: () => void)
|
||||||
|
Inherited from
NgMagicTestBed
|
||||||
|
Defined in
NgMagicTestBed:443
|
||||||
Type parameters :
|
||||||
|
Parameters :
Returns :
T
|
| Public run | ||||||
run(callbackToBeRunInInjectionContext?: () => void)
|
||||||
|
Inherited from
NgMagicTestBed
|
||||||
|
Defined in
NgMagicTestBed:444
|
||||||
Type parameters :
|
||||||
|
Parameters :
Returns :
T
|
| Public schema | ||||||||
schema(schema: SchemaMetadata | any[])
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:72
|
||||||||
|
Parameters :
Returns :
void
|
| Public schemas | ||||||||
schemas(schemas: Array
|
||||||||
|
Inherited from
NgMagicTestBed
|
||||||||
|
Defined in
NgMagicTestBed:60
|
||||||||
|
Parameters :
Returns :
void
|
| Public serviceMock | ||||||||||||
serviceMock(serviceClass: AbstractType
|
||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||
|
Defined in
NgMagicTestBed:366
|
||||||||||||
Type parameters :
|
||||||||||||
|
Parameters :
|
| Public serviceMock | |||||||||
serviceMock(serviceClass: AbstractType
|
|||||||||
|
Inherited from
NgMagicTestBed
|
|||||||||
|
Defined in
NgMagicTestBed:368
|
|||||||||
Type parameters :
|
|||||||||
|
Parameters :
|
| Public serviceMock | ||||||
serviceMock(serviceClass: AbstractType
|
||||||
|
Inherited from
NgMagicTestBed
|
||||||
|
Defined in
NgMagicTestBed:370
|
||||||
Type parameters :
|
||||||
|
Parameters :
Returns :
SpyObj<S>
|
| Public serviceMock | ||||||||||||||||
serviceMock(serviceClass: AbstractType
|
||||||||||||||||
|
Inherited from
NgMagicTestBed
|
||||||||||||||||
|
Defined in
NgMagicTestBed:380
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
|
mocks a service with the given mock
Parameters :
Returns :
|
the mock after creating some spies on it (if not disabled) |
import { NgMagicTestBed } from "../test-bed/ng-magic-test-bed.class";
export class NgMagicSetupTestBed extends NgMagicTestBed {
}