Giter Club home page Giter Club logo

testing's Introduction

Testing

npm npm npm bundle size (minified + gzip) Travis

Clean and Dry your Angular unit tests.

Why this?

Angular built with great testing tools for unit tests, but its flexibility introduces a lot of redundant code when project's components/services grow. @angeeks/testing aims to provide cleaner ways to write specs for most of common patterns with minimum efforts. And then, we can get more time for another cup of tea ๐Ÿต, cheers.

spec from official guide

import { TestBed, async } from '@angular/core/testing';
import { TediousComponent } from './tedious.component';

descirbe('handtypeed, emotional, typo prone spec title..', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        TediousComponent
      ],
    }).compileComponents();
  }));
  // frequent used test pattern
  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));
  // frequent used test pattern
  it(`should have as title 'ngk'`, async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app.title).toEqual('ngk');
  }));
});

With @angeeks/testing

import { ComponentSuite as Component } from '@angeeks/testing';
import { TediousComponent as Subject } from './tedious.component';

Component.suite<Subject>(Subject, (spec) => {
  spec.init();
  spec.expectProperty('title', 'ngk');
});

And the report will be like:

  ngk-root
    โœ“ should be created (68ms)
    โœ“ has .title to equal "ngk" (44ms)

Installation

  npm i -D @angeeks/testing

APIs

Suite.on(Subject, callback: (spec: Suite) => {})

Suite.suite(Subject, callback: (spec: Suite) => {})

  • Subject for the spec
  • callback for jasmine describe, with spec instance keep common variables

Suite.fon(Subject, callback: (spec: Suite) => {})

Suite.fsuite(Subject, callback: (spec: Suite) => {})

Same like fdescribe

testing's People

Contributors

speed-of-light avatar

Watchers

 avatar  avatar

testing's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.