Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allain/expect
helpers for writing jest like expect tests in deno
https://github.com/allain/expect
Last synced: about 2 months ago
JSON representation
helpers for writing jest like expect tests in deno
- Host: GitHub
- URL: https://github.com/allain/expect
- Owner: allain
- License: isc
- Created: 2019-04-19T23:28:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-05T02:26:22.000Z (over 1 year ago)
- Last Synced: 2024-10-17T00:58:05.029Z (about 2 months ago)
- Language: TypeScript
- Size: 65.4 KB
- Stars: 45
- Watchers: 3
- Forks: 14
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno - expect - 类似Jest语法断言测试工具. (Uncategorized / Uncategorized)
- awesome-deno-cn - @allain/expect
- awesome-deno - expect - Helpers for writing jest like expect tests in deno.![GitHub stars](https://img.shields.io/github/stars/allain/expect?style=plastic) (Modules / Online Playgrounds)
- awesome-deno - expect - Helpers for writing jest like expect tests in deno. (Modules / Testing)
- awesome-deno - expect - 类似Jest的测试辅助工具。 (模块精选 / 测试)
- awesome-deno - expect - 类似Jest的测试辅助工具。 (模块精选 / 测试)
README
# expect
[![][ghw badge]][ghw link]
A deno implementation of `expect` in order to write tests in a more `jest` like style.
```typescript
import { expect } from 'https://deno.land/x/expect/mod.ts'expect(10).toEqual(10)
expect(Promise.resolve(20)).resolves.toEqual(20)
``````typescript
interface Expected {
toBe(candidate: any, msg?: string): void
toEqual(candidate: any, msg?: string): void
toBeTruthy(msg?: string): void
toBeFalsy(msg?: string): void
toBeDefined(msg?: string): void
toBeInstanceOf(clazz: any, msg?: string): void
toBeUndefined(msg?: string): void
toBeNull(msg?: string): void
toBeNaN(msg?: string): void
toMatch(pattern: RegExp | string): void
toHaveProperty(propName: string, msg?: string): void
toHaveLength(length: number, msg?: string): void
toContain(item: any, msg?: string): void
toThrow(error?: RegExp | string, msg?: string): void// comparison
toBeGreaterThan(number: number, msg?: string): void
toBeGreaterThanOrEqual(number: number, msg?: string): void
toBeLessThan(number: number, msg?: string): void
toBeLessThanOrEqual(number: number, msg?: string): void// mock calls
toHaveBeenCalled(): void
toHaveBeenCalledTimes(times: number): void
toHaveBeenCalledWith(...args: any[]): void
toHaveBeenLastCalledWith(...args: any[]): void
toHaveBeenNthCalledWith(nth: number, ...args: any[]): void
toHaveReturnedWith(expected: any): void
toHaveReturned(): void
toHaveLastReturnedWith(expected: any): void
toHaveReturnedTimes(times: number): void
toHaveNthReturnedWith(nth: number, expected: any): voidnot: Expected
resolves: Expected
rejects: Expected
}
```[ghw badge]: https://img.shields.io/github/workflow/status/allain/expect/ci
[ghw link]: https://github.com/allain/expect/actions?query=workflow%3Aci