Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ncphillips/detest

A Deno Testing Library
https://github.com/ncphillips/detest

Last synced: about 10 hours ago
JSON representation

A Deno Testing Library

Awesome Lists containing this project

README

        

# Detest

A [Deno](https://github.com/denoland/deno) Testing Library

> We don't just hate bugs, we detest them!

## Use

```typescript
import { describe, it, test, runTests} from "./detest/detest.ts"

describe("testing", () => {
it("works", () => { 1 + 1 })"

describe("describes can be nested", () => {
test("1 + -1", () => expect(1 + (-1)).toBe(0))
test("1 + -3", () => expect(1 + (-3)).toBe(-2))
})

describe("async testing", () => {
it("is also possible", async () => {
let value = await fetchValue()

expect(value).toBe("found")
})
})

describe("before(each)", () => {
let setupValue
let resets

before(() => {
setupValue = 12345
})

beforeEach(() => {
resets = 0
})

it("should be 0", () => {
expect(resets).toBe(0)

resets++
})
it("should still be 0", () => expect(resets).toBe(0))
})
})

runTest()
```

### API

* `function describe(description: string, callback: () => void): void`
* `function it(description: string, callback: () => void | Promise): void`
* `function test`: Alias for `it`.
* `function before(callback: () => void): void`
* `function beforeEach(callback: () => void): void`
* `function expect(actual: any): DeferredExpectation`
* `class DeferredExpectation`
* `toBe(expected: any)`

## Development

Run Tests

```bash
deno detest.test.ts
```

## Roadmap

* after/afterEach
* expand expectation library
* async before(Each)