New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular2-testing-lite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-testing-lite

Jasmine-free Angular 2 Testing Library

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

angular2-testing-lite

Circle CI npm version

Jasmine-free Angular 2 Testing Library

Features

  • Jasmine-free
  • Same core API as angular2/testing
  • Less API: supports only TestInjector and TestComponentBuilder
  • Opt-in utilities for Mocha

Install

$ npm install --save-dev angular2-testing-lite

Usage (Mocha & power-assert example)

Model

Simple mocha test

import assert = require("power-assert");

describe("TestModel", () => {

    it("can instantiate", () => {
        let model = new TestModel("AAA");
        assert(!!model);
    });

    describe("toString()", () => {
        it("should return string", () => {
            const model = new TestModel("AAA");
            const str = model.toString();
            assert(typeof str === "string");
        });
    });
});

Service

Inject Http

import assert = require("power-assert");
import {async, inject} from "angular2-testing-lite/core";
import {it, describe, xdescribe, beforeEach, beforeEachProviders} from "angular2-testing-lite/mocha";

describe("TestService", () => {

    beforeEachProviders(() => [
        BaseRequestOptions,
        MockBackend,
        provide(Http, {
            useFactory: (backend: MockBackend, options: BaseRequestOptions) => {
                return new Http(backend, options);
            }, deps: [MockBackend, BaseRequestOptions]
        }),
        TestService
    ]);

    it("can instantiate", inject([TestService], (service: TestService) => {
        assert(!!service);
    }));
});

Component

Ported TestComponentBuilder

import assert = require("power-assert");
import {inject, async, TestComponentBuilder} from "angular2-testing-lite/core";
import {describe, it, xit, beforeEachProviders, beforeEach} from "angular2-testing-lite/mocha";
import {HTTP_PROVIDERS} from "@angular/http";

describe("TestAppComponent", () => {

    beforeEachProviders(() => [
        HTTP_PROVIDERS,
        TestService,
    ]);

    it("can create", async(inject([TestComponentBuilder],
        (tcb: TestComponentBuilder) => {
            return tcb.createAsync(TestAppComponent)
                .then(fixture => {
                    assert(!!fixture);
                });
        })
    ));
});

License

MIT

Keywords

FAQs

Package last updated on 03 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc