1.0.1 • Published 5 years ago

jest-decorator v1.0.1

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

Install

yarn add -D jest-decorator

Example

import { AfterAll, AfterEach, BeforeAll, BeforeEach, Describe, Test } from "jest-decorator";

@Describe("Test jest decorator")
class TestJestDecorator {
    private count: number = 0;

    @BeforeAll
    private beforeAll() {
        this.count++;
    }

    @AfterAll
    private afterAll() {
        this.count++;
    }

    @BeforeEach
    private beforeEach() {
        this.count++;
    }

    @AfterEach
    private afterEach() {
        this.count++;
    }

    @Test("count should be 2")
    private test1() {
        expect(this.count).toBe(2);
    }

    @Test("test async function")
    private async test2() {
        return new Promise(resolve => {
            setTimeout(resolve, 1000);
        });
    }

    @Test("count should be 6")
    private test3() {
        expect(this.count).toBe(6);
    }
}
1.0.1

5 years ago

1.0.0

5 years ago