Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

This package has been deprecated

Author message:

Project dropped in favour of jasmine-ts and jasmine-await

ts-test

0.0.3 • Public • Published

ts-test

build status

A collection of utilities to test typescript node applications.

It is based on jasmine.

Installation

npm i -D ts-test

Setup

  • In your package.json file create a test script:

    {
      "scripts": {
        "test": "jasmine-ts 'path/to/specs/**/*.spec.ts further/specs/**/*.spec.ts specs/to/exclude/**/*.spec.ts'"
      }
    }
  • Initialize jasmine

    node_modules/.bin/jasmine-ts init
    

Run the tests

npm test

Utilities

async

The methods it(), beforeEach(), afterEach(), beforeAll() and afterAll() are wrapped by the async module. The callback you pass is executed within an async/await environment.

Example:

import {it} from "ts-test"
 
it("should work with promises", () =>
  new Promise(resolve => setTimeout(resolve, 100))
)

HttpClient

The HttpClient wraps the request module and creates promised requests. This is intended to be used for integration tests in combination with the async module.

Example:

import {HttpClient, await} from "ts-test";
let httpClient: HttpClient;
 
beforeAll(() => {
  httpClient = new HttpClient("localhost:12341");
});
 
it("should resolve if successful", () => {
  let response = await(httpClient.get("/resources"));
  expect(response.statusCode).toEqual(200);
  expect(response.body).toEqual([{id: 42, foo: "bar"}]);
});

For more examples you can have a look at the specs for the HttpClient.

install

npm i ts-test

Downloadsweekly downloads

17

version

0.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar