@outstem/metis
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Metis

Inspired by ng-bullet, Metis is a library that aims to enhance unit testing in Angular by simplifying workflow and drastically improving Test Times.

Installation

npm install --save-dev @outstem/metis
# Or
yarn add -D @outstem/metis

Usage

import {configureTestSuite} from '@outstem/metis';

// ...

configtureTestSuite(() =>
  TestBed.configureTestingModule({
    declarations: [
      /*list of components goes here*/
    ],
    imports: [
      /* list of providers goes here*/
    ],
  }),
);

Helper Functions

createTestContext

Creates TestCtx instance for the Angular Component which is not initialized yet (no ngOnInit called)

Use case: you can override Component's providers before hooks are called.

let ctx: TestCtx<MyComponent>

beforeEach(() => {
  const ctx = createTestContext(MyComponent);
});

its(('will render') => {
  expect(ctx.component).toBeTruthy();
})

createStableTestContext

Creates TestCtx instance for the Angular Component and ask Angular to perform change detection Angular lifecycle hooks (ngOninit) will be called when using this function to initialize the test context.

let ctx: TestCtx<MyComponent>

beforeEach(async () => {
  const ctx = await createStableTestContext(MyComponent);
});

its(('will render') => {
  expect(ctx.component).toBeTruthy();
})

Readme

Keywords

none

Package Sidebar

Install

npm i @outstem/metis

Weekly Downloads

0

Version

1.0.0

License

none

Unpacked Size

92.1 kB

Total Files

15

Last publish

Collaborators

  • ebivibe
  • outstem_user
  • ddunit