1.0.31 • Published 5 years ago

tpm_testyts_2 v1.0.31

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

TestyTs

Build Status FOSSA Status

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

MIT

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago