tpm_testyts_2 v1.0.31
TestyTs
TestyTs is a modern TypeScript testing framework.
Why?
Writing tests should be fun. The other testing framework solutions do not make use of the full power of TypeScript. This one uses decorators and OOP and stuff. Therefore, it makes writing tests fun.
Installation
$ npm install --save-dev testyts
$ npm install -g testyts
Setup
To generate a testy.json configuration file, use the following cmmand:
$ testyts init
Write some tests
The basics
Writing tests with Testy is simple.
@testSuite('Sum Test Suite')
class MyTestSuite {
@test('One plus one, should equal two')
onePlusOne() {
// Act
const result = 1 + 1;
// Assert
expect.toBeEqual(result, 2);
}
}
Setup and teardown
Testy provides setup and teardown hooks.
@testSuite('Sum Test Suite')
class MyTestSuite {
@beforeAll()
beforeAll() {
// This is executed before all the test
}
@beforeEach()
beforeEach() {
// This is executed before each test
}
@afterEach()
afterEach() {
// This is executed after each test
}
@afterAll()
afterAll() {
// This is executed after all the test
}
}
Reuse code!
This is where stuff gets interesting. Testy allows you to use base test classes. The base test can have setup and teardown methods. Your child test suite may also have setup and teardown methods. In that case, the base test methods are executed before.
class MyBaseTestSuite{
// Setup/teardown extravaganza
}
@testSuite('My Test Suite')
class MyTestSuite extends MyBaseTestSuite {
// My tests
}
Asserting
There's a whole bunch of assertion methods and also a dash of syntactic sugar sexyness in the expect class.
expect.toBeTrue(2 > 1);
expect.toBeEqual('a', 'a');
expect.not.toBeEqual('p', 'np');
expect.toThrow(() => someNastyMethod());
expect.toBeSorted.inAscendingOrder([0, 1, 1, 2, 3, 5, 8]);
// More!
Run the tests
To run the tests, use the following command
$ testyts
$ testyts --config custom/config/file.json // To specify a custom configuration file
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago