# ng-test-runner

> [![Build Status](https://travis-ci.org/Pragmatists/ng-test-runner.svg?branch=master)](https://travis-ci.org/Pragmatists/ng-test-runner) [![npm version](https://badge.fury.io/js/ng-test-runner.svg)](https://badge.fury.io/js/ng-test-runner) [![Coverage Stat

Latest version **1.1.11** (published 2021-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng-test-runner
pnpm add ng-test-runner
yarn add ng-test-runner
bun add ng-test-runner
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.11 |
| Published | 2021-08-06 |
| First published | 2017-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 198.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Wojtek Przechodzeń |
| Maintainers | mpi_pragma, marmatys, woprzech, wprzecho, hubert.legec |
| Keywords | tdd, angular, test |

## Links

- npm: https://www.npmjs.com/package/ng-test-runner
- Repository: https://github.com/Pragmatists/ng-test-runner
- Homepage: https://github.com/Pragmatists/ng-test-runner#readme
- Issues: https://github.com/Pragmatists/ng-test-runner/issues
- npm.io page: https://npm.io/package/ng-test-runner

## Dependencies (2)

- [sinon](https://npm.io/package/sinon.md) ^5.1.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.11

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.1.11 (latest) — 2021-08-06
- 1.1.10 — 2020-03-23
- 1.1.9 — 2019-11-08
- 1.1.8 — 2018-12-29
- 1.1.7 — 2018-12-23
- 1.1.6 — 2018-12-13
- 1.1.5 — 2018-12-13
- 1.1.4 — 2018-12-13
- 1.1.3 — 2018-09-05
- 1.1.2 — 2018-07-13
- 1.1.1 — 2018-06-06
- 1.1.0 — 2018-03-09
- 1.0.1 — 2017-12-24
- 1.0.0 — 2017-12-18
- 0.0.1 — 2017-12-18

## README

# ng-test-runner
[![Build Status](https://travis-ci.org/Pragmatists/ng-test-runner.svg?branch=master)](https://travis-ci.org/Pragmatists/ng-test-runner)
[![npm version](https://badge.fury.io/js/ng-test-runner.svg)](https://badge.fury.io/js/ng-test-runner)
[![Coverage Status](https://coveralls.io/repos/github/Pragmatists/ng-test-runner/badge.svg?branch=master)](https://coveralls.io/github/Pragmatists/ng-test-runner?branch=master)

## Installation
To install it, type:

    $ npm install ng-test-runner --save-dev
    
## Example
Following example presents tests for simple counter component.

```typescript
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
* readable performing [actions](https://github.com/Pragmatists/ng-test-runner/wiki/Testing-DOM-interactions), e.g. clicking on elements, typing into inputs etc.
* easy request and response [server stubbing](https://github.com/Pragmatists/ng-test-runner/wiki/Testing-HTTP-interactions)
* simplified testing of code with [async operations](https://github.com/Pragmatists/ng-test-runner/wiki/Testing-HTTP-interactions#async-mode)
* easy to [write asserts](https://github.com/Pragmatists/ng-test-runner/wiki/Testing-DOM-interactions#assertions) concerning html elements

---
_Source: https://npm.io/package/ng-test-runner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
