https://github.com/shresht7/criteria
A bare minimum test framework.
https://github.com/shresht7/criteria
Last synced: 2 months ago
JSON representation
A bare minimum test framework.
- Host: GitHub
- URL: https://github.com/shresht7/criteria
- Owner: Shresht7
- License: mit
- Created: 2021-12-24T18:19:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-25T18:03:45.000Z (over 1 year ago)
- Last Synced: 2025-01-27T09:09:41.914Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Criteria
----------A super-simple bare minimum test framework.
## Usage
```ts
import { criteria } from 'criteria'
import * as assert from 'assert' // Node's builtin assert module// Random functions to test
const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)
const hyphenate = (str: string) => str.replace(/([A-Z])/, '-$1').toLowerCase()let str = 'Hello World'
let count = 0criteria('String Helpers')
.beforeEach(() => str = 'helloWorld').test('Capitalize', () => assert.deepEqual(capitalize(str), 'HelloWorld'))
.test('Hyphenate', () => assert.deepEqual(hyphenate(str), 'hello-world')).afterEach(() => console.log(`The count is ${++count}`))
```## Expect
`expect` is a chainable wrapper around Node's `assert` that allows you to add multiple validation criteria to a single statement.
```ts
import { criteria, expect } from 'criteria'const divide = (x: number, y: number) => x / y
criteria('Division')
.test('x divided by y', () => {
expect(divide(4, 2))
.toBeOkay()
.toBeOfType('number')
.toEqual(2)
})
```