1.1.11 • Published 3 years ago

ng-test-runner v1.1.11

Weekly downloads
21
License
MIT
Repository
github
Last release
3 years ago

ng-test-runner

Build Status npm version Coverage Status

Installation

To install it, type:

$ npm install ng-test-runner --save-dev

Example

Following example presents tests for simple counter component.

import test, {App, click, expectThat, http, Server} from "ng-test-runner";
import {CounterComponent, CounterModule} from './counter';

describe('Counter Component', () => {

    let app: App, server: Server;

    beforeEach(() => {
        app = test(CounterModule);
        server = http();
    });

    it('should render counter initial value', () => {
        const comp = app.run(CounterComponent, {value: 5}); // =>  <counter [value]="5"></counter>

        comp.verify(
            expectThat.textOf('.counter').isEqualTo('5')
        );
    });

    it('should increment counter value by 1', () => {
        const comp = app.run(CounterComponent, {value: 0});

        comp.perform(
            click.in('button.increment')
        );

        comp.verify(
            expectThat.textOf('.counter').isEqualTo('1')
        );
    });

    it('should send incrementation request to server', () => {
        const comp = app.run(CounterComponent, {value: 0});
        let jsonSentToServer;
        server.post('/counter/increment', req => {
            jsonSentToServer = req.body();
            req.sendStatus(200);
        });

        comp.perform(
            click.in('button.increment')
        );

        comp.verify(
            () => expect(jsonSentToServer).toEqual({counter: 1})
        );
    });

});

Features

1.1.11

3 years ago

1.1.10

4 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago