https://github.com/qoh/tes
Test runner for deno
https://github.com/qoh/tes
deno test
Last synced: 2 months ago
JSON representation
Test runner for deno
- Host: GitHub
- URL: https://github.com/qoh/tes
- Owner: qoh
- Created: 2018-10-05T19:09:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T06:30:21.000Z (about 6 years ago)
- Last Synced: 2025-03-03T10:42:39.634Z (over 1 year ago)
- Topics: deno, test
- Language: TypeScript
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Summary
Teset (pronounced Tessie) is a test runner for [deno](https://github.com/denoland/deno) based on simple concepts: exporting tests as functions (potentially nested or async), and throwing to indicate failure.
Write a test file like `example.ts`:
```javascript
export async function ok() {
// all good, your tests may be async
}
export function fail() {
throw new Error("Snowball not calibrated");
}
export const nested = {
flint() { },
deeply: {
chance() { },
},
};
```
Then run it:
```
teset example
```
```
Finding tests
Found 4 tests, running
/path/to/.../example [0ms]
✅ ok [0ms]
❌ fail [0ms]
Error: Snowball not calibrated
at Object.fail [as fn ] (file:///.../example.ts:6:8)
at ...
✅ nested.flint [0ms]
✅ nested.deeply.chance [0ms]
3/4 succeeded, 1 failed
```
## Try it
You can try this right now without installing if you have deno:
```shell
deno run --allow-read https://cdn.rawgit.com/qoh/teset/v0.2.1/src/main.ts -- \
https://cdn.rawgit.com/qoh/teset/v0.2.1/example/example.ts
```
Or with a local file:
```shell
deno run --allow-read https://cdn.rawgit.com/qoh/teset/v0.2.1/src/main.ts -- example.ts
```
# Test API
For assertions, see [assert](https://github.com/qoh/assert).
```javascript
import { ... } from "https://cdn.rawgit.com/qoh/teset/v0.2.1/src/api.ts";
```
---
```typescript
function throws(test: Function): () => Promise;
function throws(constructor: Function, test: Function): () => Promise;
function throws(message: string, test: Function): () => Promise;
function throws(constructor: Function, message: string, test: Function): () => Promise;
```
Create a test that expects `test` to throw.
Given `constructor`, the error is asserted to be an instance of it.
Given `message`, the message of the error is asserted to be equal.
```javascript
export const fails = throws(TypeError, "null is not a function", () => {
null();
});
```