ts-test
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: -
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:
it"should work with promises",new PromisesetTimeoutresolve, 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:
;; beforeAll; it"should resolve if successful",;
For more examples you can have a look at the specs for the HttpClient.