Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ng-mocks

help-me-mom1.8mMIT14.13.4TypeScript support: included

An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests. It provides shallow rendering, precise stubs to fake child dependencies. ng-mocks works with Angular 5 6 7 8 9 10 11 12 13 14 15 16 17 18, jasm

angular, test, testing, mock, mocking, component, directive, pipe, provider, service, TestBed, how-to, frontend, front-end, jest, jasmine, enzyme, stub, dependency

readme

chat on gitter npm version build status coverage status

Mock components, services and more out of annoying dependencies for simplification of Angular testing

ng-mocks facilitates Angular testing and helps to:

  • mock Components, Directives, Pipes, Modules, Services and Tokens
  • reduce boilerplate in tests
  • access declarations via simple interface

The current version of the library has been tested and can be used with:

angular ng-mocks jasmine jest ivy standalone signals defer
19 latest yes yes yes yes no no
18 latest yes yes yes yes no no
17 latest yes yes yes yes no no
16 latest yes yes yes yes no
15 latest yes yes yes yes |
14 latest yes yes yes yes |
13 latest yes yes yes |
12 latest yes yes yes |
11 latest yes yes yes |
10 latest yes yes yes |
9 latest yes yes yes |
8 latest yes yes | |
7 latest yes yes | |
6 latest yes yes | |
5 latest yes yes |

Very short introduction

Global configuration for mocks in src/test.ts. In case of jest, src/setup-jest.ts / src/test-setup.ts should be used.

`ts title="src/test.ts" // All methods in mock declarations and providers // will be automatically spied on their creation. // https://ng-mocks.sudo.eu/extra/auto-spy ngMocks.autoSpy('jasmine'); // or jest

// ngMocks.defaultMock helps to customize mocks // globally. Therefore, we can avoid copy-pasting // among tests. // https://ng-mocks.sudo.eu/api/ngMocks/defaultMock ngMocks.defaultMock(AuthService, () => ({ isLoggedIn$: EMPTY, currentUser$: EMPTY, }));


An example of a spec for a profile edit component.

```ts title="src/profile.component.spec.ts"
// Let's imagine that there is a ProfileComponent
// and it has 3 text fields: email, firstName,
// lastName, and a user can edit them.
// In the following test suite, we would like to
// cover behavior of the component.
describe('profile:builder', () => {
  // Helps to reset customizations after each test.
  // Alternatively, you can enable
  // automatic resetting in test.ts.
  MockInstance.scope();

  // Let's configure TestBed via MockBuilder.
  // The code below says to mock everything in
  // ProfileModule except ProfileComponent and
  // ReactiveFormsModule.
  beforeEach(() => {
    // The result of MockBuilder should be returned.
    // https://ng-mocks.sudo.eu/api/MockBuilder
    return MockBuilder(
      ProfileComponent,
      ProfileModule,
    ).keep(ReactiveFormsModule);
    // // or old fashion way
    // return TestBed.configureTestingModule({
    //   imports: [
    //     MockModule(SharedModule), // mock
    //     ReactiveFormsModule, // real
    //   ],
    //   declarations: [
    //     ProfileComponent, // real
    //     MockPipe(CurrencyPipe), // mock
    //     MockDirective(HoverDirective), // mock
    //   ],
    //   providers: [
    //     MockProvider(AuthService), // mock
    //   ],
    // }).compileComponents();
  });

  // A test to ensure that ProfileComponent
  // can be created.
  it('should be created', () => {
    // MockRender is an advanced version of
    // TestBed.createComponent.
    // It respects all lifecycle hooks,
    // onPush change detection, and creates a
    // wrapper component with a template like
    // <app-root ...allInputs></profile>
    // and renders it.
    // It also respects all lifecycle hooks.
    // https://ng-mocks.sudo.eu/api/MockRender
    const fixture = MockRender(ProfileComponent);

    expect(
      fixture.point.componentInstance,
    ).toEqual(assertion.any(ProfileComponent));
  });

  // A test to ensure that the component listens
  // on ctrl+s hotkey.
  it('saves on ctrl+s hot key', () => {
    // A fake profile.
    const profile = {
      email: 'test2@email.com',
      firstName: 'testFirst2',
      lastName: 'testLast2',
    };

    // A spy to track save calls.
    // MockInstance helps to configure mock
    // providers, declarations and modules
    // before their initialization and usage.
    // https://ng-mocks.sudo.eu/api/MockInstance
    const spySave = MockInstance(
      StorageService,
      'save',
      jasmine.createSpy(), // or jest.fn()
    );

    // Renders <profile [profile]="params.profile">
    // </profile>.
    // https://ng-mocks.sudo.eu/api/MockRender
    const { point } = MockRender(
      ProfileComponent,
      { profile }, // bindings
    );

    // Let's change the value of the form control
    // for email addresses with a random value.
    // ngMocks.change finds a related control
    // value accessor and updates it properly.
    // https://ng-mocks.sudo.eu/api/ngMocks/change
    ngMocks.change(
      '[name=email]', // css selector
      'test3@em.ail', // an email address
    );

    // Let's ensure that nothing has been called.
    expect(spySave).not.toHaveBeenCalled();

    // Let's assume that there is a host listener
    // for a keyboard combination of ctrl+s,
    // and we want to trigger it.
    // ngMocks.trigger helps to emit events via
    // simple interface.
    // https://ng-mocks.sudo.eu/api/ngMocks/trigger
    ngMocks.trigger(point, 'keyup.control.s');

    // The spy should be called with the user
    // and the random email address.
    expect(spySave).toHaveBeenCalledWith({
      email: 'test3@em.ail',
      firstName: profile.firstName,
      lastName: profile.lastName,
    });
  });
});

Profit.

Extra

If you like ng-mocks, please support it:

Thank you!

P.S. Feel free to contact us if you need help.

changelog

14.13.4 (2025-03-11)

Bug Fixes

  • core: standalone optimization and ngx-translate e2e integration #10752 (eda80eb)
  • core: standalone optimization and ngx-translate e2e integration #10752 (#11186) (b090d40)
  • ngMocks.findTemplateRef: detects NgTemplates correctly #11179 (a88afb8)
  • ngMocks.reveal: detects nodes correctly #11182 (0b7af2d)

14.13.3 (2025-03-09)

Bug Fixes

14.13.2 (2025-01-12)

Bug Fixes

14.13.1 (2024-08-25)

Bug Fixes

  • unable to bind ngIf in angular 17+ (7c816e6), closes #8884

14.13.0 (2024-06-01)

Features

14.12.2 (2024-04-13)

Bug Fixes

  • unable to find instance in case of ng17 control flow (f6418d7), closes #7216

14.12.1 (2023-11-19)

Bug Fixes

  • undefined issue with some modules (8045447)

14.12.0 (2023-11-18)

Bug Fixes

  • ci: running npm after nvm #6505 (5a115a7)
  • docs: Fixed typo in MockBuilder docs (3fa9b54)
  • MockBuilder: detecting parent modules to build correct TestBed #6928 (2d0012c)
  • MockBuilder: respects global rules as they would be chain calls #6402 (23d9ba6)
  • ng-mocks: a17 support (ea19983)
  • ngMocks: respects custom errors on lookups #7041 (6c78f54)

Features

  • MockBuilder: supports EnvironmentProviders #7011 (b3ca1d4)

14.11.0 (2023-06-11)

Bug Fixes

  • MockService: respects prototypes of customizations #5989 (e9945fe)

Features

  • MockBuilder: can be extended with custom methods #5417 (8da8c9d)

14.10.1 (2023-05-13)

Bug Fixes

  • MockInstance: multi-token and multi-service #5585 (9c85dea)

14.10.0 (2023-04-23)

Bug Fixes

  • core: better eval code to extend es6 classes #5465 (2dd66cd)
  • MockBuilder: touches kept modules in standalone components #5520 (1589172)

Features

  • core: supporting functional guards and resolvers #5455 (d8a13c1)

14.9.0 (2023-04-15)

Features

14.8.0 (2023-04-02)

Features

14.7.3 (2023-03-26)

Bug Fixes

  • MockBuilder: configuration first, process later #5239 (992ef6a)
  • MockBuilder: respects pipe-transform in early mocks #5239 (979d42b)

14.7.2 (2023-03-25)

Bug Fixes

14.7.1 (2023-03-10)

Bug Fixes

14.7.0 (2023-03-05)

Bug Fixes

  • deps: update nrwl monorepo to v15.8.5 (f73f25a)

Features

14.6.0 (2023-01-21)

Features

  • core: ViewContainerRef.createComponent respects mocks #4742 (bd93b7b)

14.5.3 (2023-01-15)

Bug Fixes

  • MockBuilder: precise exports via TestBed.configureTestingModule #4641 (66a8ecc)

14.5.2 (2023-01-06)

Bug Fixes

  • MockBuilder: imports modules with providers on root level #4613 (3ed8ae4)

14.5.1 (2022-12-24)

Bug Fixes

  • core: correctly defines TestBed with multiple declarations with the same selector #4564 (1e01f82)
  • core: respecting transform in mock pipes #4564 (df51240)

14.5.0 (2022-12-11)

Features

  • core: hidden usage of MockBuilder in TestBed if kept and mock modules are used together #4344 (d77b6f2)
  • MockInstance: ignores undefined properties #4367 (70d9781)

14.4.0 (2022-11-27)

Bug Fixes

  • a15: adding NG_MOCKS_ROOT_PROVIDERS for RouteReuseStrategy (737247d)
  • core: correct caching of touched declarations #4344 (233f014)

Features

  • MockBuilder: mocks root providers via inject function #4282 (dc7026e)

14.3.4 (2022-11-22)

Bug Fixes

  • core: respecting schemas in mock modules #4228 (b13bf34)
  • core: support for EnvironmentProviders (bcb8112)

14.3.3 (2022-11-12)

14.3.2 (2022-10-30)

Bug Fixes

  • MockRender: respecting customizations for declarations without selectors #4032 (880f5dd)

14.3.1 (2022-10-23)

Bug Fixes

14.3.0 (2022-10-13)

Features

  • MockRender: the host element doesn't have ngContext attribute anymore #3811 (0138df7)

14.2.4 (2022-10-09)

Bug Fixes

  • core: exporting internal types #3709 (8b9cb23)
  • core: providers with useExisting will be kept if their value is a kept declaration #3778 (4ef2885)

14.2.3 (2022-09-24)

Bug Fixes

  • MockBuilder: better detection of provided dependencies #3635 (4e9aeab)
  • MockRender: does not throw on standalone declarations #3636 (b2de841)

14.2.2 (2022-09-18)

Bug Fixes

14.2.1 (2022-09-09)

Bug Fixes

14.2.0 (2022-08-21)

Features

  • ngMocks: supports custom method names for change and touch #3341 (5068407)

14.1.3 (2022-08-09)

Bug Fixes

14.1.2 (2022-08-07)

Bug Fixes

  • MockBuilder: respects initial config of declarations #3265 (1bea651)

14.1.1 (2022-07-31)

Bug Fixes

  • MockBuilder: respects global configuration for standalone dependencies #3161 (577e1d4)

14.1.0 (2022-07-15)

Bug Fixes

  • core: detecting and mocking standalone directives correctly #3100 (560b334)
  • core: preventing recursion of self pointers #3095 (793a3c5)

Features

14.0.2 (2022-07-11)

14.0.1 (2022-06-19)

Bug Fixes

14.0.0 (2022-06-18)

Bug Fixes

  • MockBuilder: respect extension of classes with different decorators #2646 (d069a90)

Features

  • core: Support of standalone declarations #2687 (797cec3)
  • MockBuilder: default flags as dependency or export #2647 (f37a663)

BREAKING CHANGES

  • MockBuilder: MockBuilder with 2 params marks all chain calls as dependency
  • MockBuilder: MockBuilder with 0-1 params marks all chain calls as export

13.5.2 (2022-05-14)

Bug Fixes

  • core: correct type for AbstractType (6fbf18d)
  • core: using this as global object (5d21523)

13.5.1 (2022-05-07)

Bug Fixes

  • MockRender: renders pipes with $implicit param #2398 (03f5f5e)

13.5.0 (2022-05-01)

Bug Fixes

  • ngMocks.findInstance: finds pipes in attributes #2314 (1b8868f)
  • ngMocks.findInstance: works without fixture #2311 (7752914)

Features

  • MockProvider: simple generators for different types #599 (9d90121)

13.4.2 (2022-04-11)

Bug Fixes

13.4.2-alpha.1 (2022-04-11)

Bug Fixes

13.4.1 (2022-04-10)

Bug Fixes

13.4.0 (2022-04-03)

Bug Fixes

  • a14: injecting mock components in vcr.createComponent #333 (f3e5fd9)
  • core: BrowserAnimationsModule is optional dependency now #1377 (6f4e8da)
  • core: removing isNgModuleDefWithProviders from exports #2173 (7501dc9)

Features

  • core: BrowserAnimationsModule better coverage #1377 (a2eaf88)

13.3.0 (2022-03-27)

Bug Fixes

  • core: better error messages #1168 (cad1efb)
  • ngMocks.stubMember: forwarding stub values to point.componentInstance #1165 (3450e1d)

Features

  • ngMocks.findInstance: looks for instances in all matched DebugElements #2105 (bb39517)
  • ngMocks.findInstance: supports tokens #2097 (9387209)

Performance Improvements

13.2.0 (2022-03-20)

Bug Fixes

  • MockInstance: correctly accepts falsy values #2087 (8900fc3)

Features

  • ngMocks.defaultConfig: config for MockBuilder #971 (9415f57)

13.1.1 (2022-03-12)

Bug Fixes

  • a14: adding a14 to peerDependencies (e76b644)
  • core: generic in getMockedNgDefOf #985 (567908d)

13.1.0 (2022-03-06)

Bug Fixes

Features

  • MockInstance: resets root overrides likewise properties #1256 (a903556)

13.0.4 (2022-02-27)

Bug Fixes

13.0.3 (2022-02-20)

Bug Fixes

  • mock-render: apply overrides to components with no selectors #1876 (b032746)

13.0.2 (2022-02-06)

Bug Fixes

  • ie: running IE on A5 and old nodejs (087d58d)

13.0.1 (2022-02-06)

Bug Fixes

13.0.0 (2022-01-23)

Bug Fixes

  • a13: creating known props and methods (5386f77)
  • a13: parsing a9 declarations (b12e00a)
  • core: correct resets on errors (e3b1809)
  • core: ignoring host bindings in mocks #1427 (411842c)
  • core: parsing only own declarations #1587 (978bdbc)

Features

BREAKING CHANGES

  • a13: Angular 13 only support

13.0.0-alpha.6 (2022-01-18)

Bug Fixes

13.0.0-alpha.5 (2022-01-17)

Bug Fixes

13.0.0-alpha.4 (2022-01-16)

Bug Fixes

  • core: correct resets on errors (e3b1809)

13.0.0-alpha.3 (2022-01-15)

Bug Fixes

  • a13: creating known props and methods (5386f77)
  • a13: parsing a9 declarations (b12e00a)

13.0.0-alpha.2 (2022-01-09)

Features

  • a13: recursive declarations (396573f)

13.0.0-alpha.1 (2022-01-08)

Features

BREAKING CHANGES

  • a13: Angular 13 only support

12.5.1 (2021-12-20)

12.5.0 (2021-09-13)

Bug Fixes

  • MockInstance: proper reset on empty config #1046 (7d1642d)

Features

12.4.0 (2021-07-25)

Features

  • core: internal stack integration with mocha runner #838 (14a97d0)
  • MockInstance: console.warn on forgotten resets #857 (3e35252)
  • MockInstance: manual control of mock scopes #857 (fc8a2ed)

12.3.1 (2021-07-04)

Bug Fixes

  • core: right storage of internal stacks (ba0b64b)

12.3.0 (2021-07-03)

Bug Fixes

  • core: using commonjs only because of optional packages #761 (adbad49)
  • jest: better detection and error reporting of jest.mock #760 (0903a12)
  • MockBuilder: params support tokens and modules with providers #762 (d58693e)

Features

  • ngMocks: allows to suppress console logs #578 (ee1c6bb)

12.2.0 (2021-06-30)

Bug Fixes

  • core: allowing spies on ComponentFactoryResolver.resolveComponentFactory #736 (fda714e)
  • core: mock of mock will return itself (4358b99)

Features

  • core: mock for root and platform definitions #735 (04128b6)
  • core: throw on console can accept custom method names (fecc878)

12.1.2 (2021-06-20)

Performance Improvements

  • mock-render: caching generated component #731 (66e23c5)

12.1.1 (2021-06-19)

Bug Fixes

  • core: building cjs and mjs #702 (f11c086)
  • core: supports mocks for viewProviders #726 (68f9946)
  • faster: support for pure TestBed #721 (d4e0c8a)
  • mock-builder: provides globally exported providers from directives and components #623 (58ee0d8)

12.1.0 (2021-06-05)

Bug Fixes

  • core: excluding StoreDevtoolsModule by default #589 (c376e93)
  • core: supporting jest-circus as a test runner #610 (aaa0380)
  • jest: a fix in advance to listen to jest hooks #610 (1290c8a)
  • mock-builder: keeps and mocks modules with providers properly #625 (4d4ff49)
  • mock-render: factory can be used in describes #629 (f440760)
  • mock-render: skipping proxy for bindings from factory #621 (f4dae60)

Features

  • core: replacing animations with noop by default #641 (ca65de3)

Reverts

  • Revert "chore(deps): update dependency jest to v27" (1f4bd9a)

12.0.2 (2021-05-25)

Bug Fixes

  • mock-render: default to onTestBedFlushNeed = warn #593 (a9e535c)
  • mock-render: dynamic params and cdr for factory #586 (73f54c5)

12.0.1 (2021-05-21)

Bug Fixes

  • core: a config parameter to suppress MockRender errors #572 (bcfe23a)
  • core: broken query selectors are properly normalized #567 (9c1ea70)
  • default-mock: supports an array with declarations #568 (5d3b43e)
  • default-mock: supports generic type in array signature #583 (c925818)
  • faster: supports directives and components without selectors #576 (599c7d5)
  • mock-render: allowing to disable flush TestBed warning (6131ecb)
  • mock-render: providing a MockRenderFactory in order to reuse the same middleware component (79fa336)

Performance Improvements

  • core: switching internal stack to an array instead of a set (24c4bfd)

12.0.0 (2021-05-13)

Features

  • official support of Angular 12 (d63c34f)

BREAKING CHANGES

  • auto spy should be installed via ngMocks.autoSpy

11.11.2 (2021-05-13)

Bug Fixes

  • core: properly handling Sanitizer and DomSanitizer #538 (fb51bb4)
  • mock-render: detectChanges flag has to be provided to suppress render (8195eeb)

11.11.1 (2021-05-09)

Bug Fixes

  • mock-render: binds all inputs on no params #522 (dd5abba)

11.11.0 (2021-05-09)

Bug Fixes

  • mock-builder: overrides mock modules for platform #435 (bf469bc)
  • mock-builder: respecting forward-ref and modules with providers #312 (4a099b8)
  • overrides as functions are properly cloned #455 (9310d34)
  • skipping wrong query selectors #445 (6750939)
  • supporting new structure of lView (8d3cadf)
  • #333: register mock components with entryComponents (3a53431), closes #333

Features

  • faster: supports MockRender in beforeAll #488 (df4418c)
  • mock-builder: accepts arrays in params #386 (c8d8e40)
  • mock-render: generates tpl only for provided inputs and outputs #434 (23d45a2)
  • mock-render: throws on wrong usage #488 (b4a62bc)
  • almost all ngMocks helpers support css selectors #317 (b348842)

11.10.1 (2021-04-12)

Bug Fixes

  • #354: better error instead of is not in JIT mode (45f05fb), closes #354
  • #377: respect of providedIn in Injectable (91aba4b), closes #377

11.10.0 (2021-04-04)

Bug Fixes

  • #316: better support for typeIn and ngModel (7d03c2d), closes #316
  • #320: full implementation of ngMocks.touch and ngMocks.change (fd81409), closes #320
  • #324: smarter touches and changes (fa418d0), closes #324

Features

  • #314: ngMocks.formatText (fa3cea7), closes #314
  • #315: ngMocks.trigger and ngMocks.click (2ae6e5a), closes #315

11.9.1 (2021-03-14)

Bug Fixes

  • supporting schematics for updates (8e30404)

11.9.0 (2021-02-27)

Bug Fixes

  • #305: better injection of NgControl (f85f497), closes #305

Features

11.8.0 (2021-02-25)

Features

11.7.0 (2021-02-19)

Bug Fixes

  • cannot set property 'form' of undefined (a7b60e9), closes #302
  • correct replacement of useExisting providers (6908e5f)

Features

11.6.0 (2021-02-14)

Bug Fixes

  • all find functions can handle undefined debug element (397ecf8)
  • better types (bd7f72b)
  • correct stop of search in ivy tree (952986e), closes #298
  • issue of useExisting and mat components (0714da8)

Features

  • find TemplateRef / ng-template (093eea7), closes #290
  • support of A12 (4627fe2), closes #293
  • #288: correct render for ContentChild properties (5fec515), closes #288

11.5.0 (2021-01-22)

Bug Fixes

Features

  • mock-instance: simpler interface (0306643)

11.4.0 (2021-01-17)

Bug Fixes

  • descriptor.configurable = true (68a8751)
  • guts: respect ngMocks.default (59bb586)
  • mock-instance: a separate config scope (a0c930c)
  • mock-module: excludes modules with providers correctly (b5cb39c), closes #271
  • mock-render: static selector for declarations w/o selector (8f39d1f)
  • @angular/forms is optional (bfaf495)
  • avoiding cache in providers' declaration (da98414)
  • grouping similarities (e1bc77b)

Features

  • ng-mocks: ngMocks.stubMember returns passed value (27f5404)
  • ng-mocks: renaming ngMocks.default to ngMocks.global (d9f46d3)
  • ng-mocks: ngMocks.stubMember (efcd175)
  • ng-mocks: ngMocks.throwOnConsole (7b0f2f8)
  • ng-mocks: ngMocks.globalExclude (bdd2821)
  • ng-mocks: ngMocks.globalKeep (e89b876)
  • ng-mocks: ngMocks.globalReplace (330868f)
  • ng-mocks: ngMocks.globalWipe (cb71bdb)

11.3.1 (2021-01-02)

Bug Fixes

  • declarations w/o selectors are reachable with ngMocks helpers (ac26d81), closes #266

11.3.0 (2021-01-01)

Bug Fixes

Features

  • mock-render: renders everything (f33a132), closes #266

11.2.8 (2020-12-27)

Bug Fixes

  • removal dependency on decorators (92064d4)
  • removal dependency on reflect-metadata (57cedfb)

11.2.7 (2020-12-25)

Bug Fixes

  • mock-instance: graceful reset after specs (2e395df)
  • mock-instance: supports tokens (92abb82)

11.2.6 (2020-12-21)

Bug Fixes

  • auto-spy: in legacy parts too (114ae22)

11.2.5 (2020-12-20)

Bug Fixes

  • auto-spy: as a function call instead of import (3b7d8f7)

11.2.4 (2020-12-13)

Bug Fixes

  • now MockRender's proxy component respects outside params changes (9297cd1)

11.2.3 (2020-12-10)

Bug Fixes

  • #246: auto spy covers control value accessor too (5c5b003), closes #246
  • #248: handling null and undefined in declarations (13b9e4e), closes #248
  • correct overriding order for pipes (750153d)

11.2.2 (2020-12-05)

Bug Fixes

  • auto-spy covers pipes with default transform (980b4d7)

11.2.0 (2020-12-04)

Bug Fixes

  • ngMocks.guts reuses mock pipes (13dd2c9), closes #241

Features

  • global configuration for default mocks (29715f8), closes #226
  • impure pipes support + .get, .findInstance can find them in fixtures (efa6337), closes #240
  • now .mock extends by default, use precise flag to get old behavior (bf576fd)

11.1.4 (2020-11-29)

Bug Fixes

11.1.3 (2020-11-26)

Bug Fixes

  • clear return statements in the docs (44b12e4)

11.1.2 (2020-11-25)

Bug Fixes

  • issue with mock multi token providers (774f171)

Performance Improvements

11.1.1 (2020-11-21)

Bug Fixes

11.1.0 (2020-11-20)

Features

  • overrides for MockService (6492a3e)

11.0.0 (2020-11-15)

Bug Fixes

  • removing deprecations (2625352)
  • respecting internals vs externals (d4abf41), closes #44

Features

BREAKING CHANGES

  • respects internals vs externals, to access them use guts or MockBuilder
  • removed NG_GUARDS, use NG_MOCKS_GUARDS
  • removed NG_INTERCEPTORS, use NG_MOCKS_INTERCEPTORS
  • removed custom meta in MockComponent
  • removed MockHelper, use ngMocks
  • A11

10.5.4 (2020-11-14)

Bug Fixes

  • better handling of double decorations (60bbebc)
  • flex behavior for a mock pipe (9769061)
  • searching for things in default fixture (17b5208)

10.5.3 (2020-11-07)

Bug Fixes

  • an example how to handle "TypeError: Cannot read property 'subscribe' of undefined" (6501a87), closes #226
  • info how to solve "type is part of the declarations of 2 modules" (f5ee1bc)
  • mock-render proxy (eaeabba)
  • relaxed signature of MockInstance (dccaa2d)

10.5.2 (2020-11-04)

Bug Fixes

  • keeping root providers for kept modules (dc078af), closes #222
  • providing a root service as it is for kept declarations (e5486e6), closes #222
  • respecting mock keep switch in nested modules (2f185fb)
  • support of ngOnChanges from OnChanges interface (820dc94)

10.5.1 (2020-11-01)

Bug Fixes

  • mocking custom deps of providers (87da53b)
  • providing MockProvider and its docs (ecfb15d)

10.5.0 (2020-10-30)

Bug Fixes

  • mocking token more intelligently (0f7cc0c)
  • supporting null as keepDeclaration of MockBuilder (5f44445)
  • supporting pipes in providers (6e252e8), closes #218

Features

  • detecting global providers and mocking them (a36a9df)
  • exclude feature for ngMocks.guts (1886fd1)
  • token to exclude all guards (7068784)
  • token to exclude all interceptors (660f4c4)

10.4.0 (2020-10-24)

Features

  • exportAll flag for modules (5f8835c)
  • ngMocks.guts for easy start (d19f958)
  • supporting fixture in ngMocks.find (26da8a4)

10.3.0 (2020-10-18)

Features

  • ngMocks.faster execution of test suites (a077d15)

10.2.1 (2020-10-10)

Bug Fixes

  • builds with proper mappings (72ed700)
  • mocking private service in component (ab43a43), closes #198
  • more intelligent overrides (b17ff7f)
  • more restricted stub signature (fc179db)
  • performance degradation caused by .exclude feature (3bf29ad)
  • support of modules with providers in MockBuilder (e0250e0), closes #197

10.2.0 (2020-10-03)

Features

  • angular 11 support (af50a72)
  • exclude feature in MockBuilder (d839f27), closes #175
  • mocked providers for kept declarations (062d147), closes #172

Bug Fixes

  • cache break of MockComponent (4b0ea25), closes #96
  • generic type constraint for ngMocks.stub tedious to write (cccd96d), closes #166

10.1.3 (2020-09-13)

Bug Fixes

  • cannot combine @Input decorators with query decorators (7cda85d), closes #181
  • respecting initialization of providers between tests (2c7b47d), closes #186

10.1.2 (2020-08-09)

Bug Fixes

  • mocking getter and setters of services (5a0ac7c), closes #177
  • mocking imports after declarations (ab3aa6f), closes #178

10.1.1 (2020-07-21)

Bug Fixes

  • unexpected value '[object Object]' exported by the module (148d659), closes #173

10.1.0 (2020-07-19)

Features

  • extending mocked things via MockInstance (1ab2c9d), closes #170

Bug Fixes

  • injection of NG_VALIDATORS and NgControl (82dd56a), closes #167

10.0.2 (2020-07-12)

Bug Fixes

  • skipping mocking of EventManager and DomSharedStylesHost (84b2720), closes #162

10.0.1 (2020-07-12)

Bug Fixes

  • building es5 only that supports es2015 (d11ed5a), closes #158
  • respect mocks in tokens with useValue (ccccfc6), closes #151
  • smart injection of NG_VALUE_ACCESSOR (ad37bf0), closes #157

10.0.0 (2020-07-05)

Features

BREAKING CHANGES

  • A10

9.6.4 (2020-07-02)

Bug Fixes

  • respect of WithProviders without providers (11ec9de), closes #151

9.6.3 (2020-06-23)

Bug Fixes

  • adding NG_VALUE_ACCESSOR only when necessary (7f54464), closes #145

9.6.2 (2020-06-21)

Bug Fixes

  • detection of empty modules in mock process (7427e29), closes #142

9.6.1 (2020-06-14)

Bug Fixes

  • better default type of MockedComponentFixture (cca6994)

9.6.0 (2020-06-14)

Features

  • e2e tests for all angular versions (7bc10a7)
  • mock-builder + lots of helpers (6965ec0), closes #44
  • mock-render tries to mirror passed component (cbb37ba), closes #137

9.5.0 (2020-05-31)

Bug Fixes

  • ngMocks instead of MockHelper (1db914c), closes #131
  • throw a human readable error during resolve (284e848), closes #133

Features

  • ease of getting inputs and outputs (af9a846), closes #129
  • mock-service is typed and supports overrides (805e37b), closes #122

9.4.0 (2020-05-17)

Bug Fixes

  • better docs with current features (c76209f)

Features

  • original instanceof and properties (05dd90b), closes #109

9.3.0 (2020-05-10)

Bug Fixes

  • correct mocking of xxxChild(ren) decorators (de7b8c3), closes #109
  • improved helpers and documentation (9ef24a0)
  • more friendly return type of mock-render (f4a3b79)
  • remove usage of unknown (26dfdb8)

Features

  • MockHelper with find, findAll and OrFail (ecc4ac7)
  • providers for MockRender (cb656b7), closes #102
  • support injection a library-related service mocker (e6be694), closes #87 #103
  • type-safe MockRender (3bfe7bf)

9.2.0 (2020-03-28)

Bug Fixes

9.1.0 (2020-03-21)

Features

  • Base class for directives and components (f47853e)
  • MockService (62a87ea)
  • mock-render: option to detectChanges or not (236b9e0)

9.0.0 (2020-02-11)

8.1.0 (2019-07-17)

Bug Fixes

  • es2015 class declaration method mocking (1286b10)

8.0.0 (2019-06-03)

Features

7.8.0 (2019-05-14)

Features

  • 51: Add mocked entry components to mocked modules (a321b14)

7.7.2 (2019-04-26)

7.7.1 (2019-04-23)

Bug Fixes

  • 49: stop caching mocked pipes (058d66e)

7.7.0 (2019-03-15)

7.6.0 (2019-02-26)

7.5.0 (2019-01-29)

7.4.0 (2018-12-22)

7.3.0 (2018-12-18)

7.2.0 (2018-12-07)

7.1.3 (2018-12-02)

7.1.2 (2018-11-26)

7.1.1 (2018-11-06)

7.1.0 (2018-11-01)

Bug Fixes

  • trim innerText that was getting a new line from a div (f883ad0)

7.0.1 (2018-10-26)

Bug Fixes

  • package-lock out of sync (6fe7d36)

7.0.0 (2018-10-26)

6.3.0 (2018-10-17)

Features

  • MockDirective: added the ability to use ViewChild/ViewChildren etc with MockDirective (8853e87)

6.2.3 (2018-10-02)

Bug Fixes

  • MockPlural: removing generic type from MockComponents, Directives, and Pipes (919a06c)

6.2.2 (2018-10-02)

Bug Fixes

  • MockModule: Never mock CommonModule (119dd80)

6.2.1 (2018-08-28)

6.2.0 (2018-08-28)

Features

  • add a MockedComponent type (fe547af)

6.1.0 (2018-06-04)

Features

  • support structural directives (050e70c)

6.0.1 (2018-05-15)

Bug Fixes

  • package json peer dep version range (8ad3834)

6.0.0 (2018-05-14)

Features

  • support angular 6 and test 5 & 6 in travis (5bc9331)

5.3.0 (2018-04-05)

Features

  • MockOf - Include mocked class names in mock class names (8b149f5)

5.2.0 (2018-03-30)

Features

  • Use Angular annotation resolvers (4050d10)

5.1.0 (2018-03-25)

Bug Fixes

  • Add a null check for decorator args (1058044)

Features

  • Support Angular propDecorators inputs and outputs (add374d)

5.0.0 (2018-03-25)

Bug Fixes

  • Fix bad return value from mock-directive (4659a32)
  • multiple decorators on an input (13874b9)
  • Outdated package-lock (7623e98)

Features

  • add functions to mass mock (fee5a03)
  • Cleanup exports and export MockDeclaration from MockModule (9fe2bb1)
  • mock directives now have event emitter bound outputs (bac1ca5)

5.0.0-rc5 (2018-03-07)

Bug Fixes

  • package json typings location (5f6fde0)

5.0.0-rc4 (2018-03-07)

5.0.0-rc3 (2018-03-07)

Bug Fixes

Features

  • merge in mock-module (05eaebe)
  • support inputs and outputs from extended components (fc46838)

5.0.0-rc1 (2018-02-10)

Bug Fixes

  • add reflect-metadata back to devDeps (385c9c4)
  • Add support for directives with a different kind of meta (0bd38cc)
  • add testbed test that exposed now fixed issue (610cbdc)
  • forgot how to use js reduce (de518d4)
  • instantiate event emitters in component constructor (fb4b97d)
  • module exports is now all declarations (fbb0e73)
  • output binding (59f476d)
  • works with component w/o inputs or outputs (b3d38e7)

Features

  • add exportAs and alias support (14a1474)
  • add support for exportAs and input aliases (9b42a21)
  • Adding angular 2 compatibility and moving to peerDependency (#3) (4bd93db)
  • component mock implements control value accessor to support ngModel binding (67ea7c4)
  • initial implementation (893f83b)
  • memoize function by arg (031e3a6)
  • memoize function by arg (cac00b3)
  • mock module providers (49b2272)
  • Upgrade to angular 5 and pull in testbed for tests (7df64a8)