# jest-decorator

> Write unit tests for jest using typescript class

Latest version **1.0.1** (published 2019-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install jest-decorator
pnpm add jest-decorator
yarn add jest-decorator
bun add jest-decorator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-09-06 |
| First published | 2019-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | wangqj |
| Maintainers | qpalzmqaz123 |

## Links

- npm: https://www.npmjs.com/package/jest-decorator
- Repository: https://github.com/qpalzmqaz123/jest-decorator
- Homepage: https://github.com/qpalzmqaz123/jest-decorator#readme
- Issues: https://github.com/qpalzmqaz123/jest-decorator/issues
- npm.io page: https://npm.io/package/jest-decorator

## Dependencies (1)

- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 1.0.1 (latest) — 2019-09-06
- 1.0.0 — 2019-09-06

## README

## Install

```bash
yarn add -D jest-decorator
```

## Example

```typescript
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);
    }
}
```

---
_Source: https://npm.io/package/jest-decorator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
