lawest
v0.1.1
Published
[![NPM version](https://img.shields.io/npm/v/lawest?color=a1b858&label=)](https://www.npmjs.com/package/lawest)
Downloads
3
Readme
lawest
A blazing fast test runner powered by Vite.
Features
- Vite's transformer, resolver, and plugin system. Powered by vite-node.
- Jest Snapshot.
- Chai for assertions.
- Async suite / test.
- ESM friendly, top level await.
- Suite and Test filtering (skip, only, todo).
import { assert, describe, expect, it } from 'lawest'
describe('suite name', () => {
it('foo', () => {
assert.equal(Math.sqrt(4), 2)
})
it('bar', () => {
expect(1 + 1).eq(2)
})
it('snapshot', () => {
expect({ foo: 'bar' }).toMatchSnapshot()
})
})
$ npx lawest
Global APIs
By default, lawest
does not provide global APIs for explicitness. If you prefer to use the APIs globally like Jest, you can pass the --global
option to CLI or add global: true
in the config.
// vite.config.ts
import { defineConfig } from 'vite'
export default defineConfig({
test: {
global: true,
},
})
To get TypeScript working with the global APIs, add lawest/global
to the types
filed in your tsconfig.json
// tsconfig.json
{
"compilerOptions": {
"types": [
"lawest/global"
]
}
}
Filtering
Skipping suites and tasks
Use .skip
to avoid running certain suites or tests
describe.skip('skipped suite', () => {
it('task', () => {
// Suite skipped, no error
assert.equal(Math.sqrt(4), 3)
})
})
describe('suite', () => {
it.skip('skipped task', () => {
// Task skipped, no error
assert.equal(Math.sqrt(4), 3)
})
})
Selecting suites and tests to run
Use .only
to only run certain suites or tests
// Only this suite (and others marked with only) are run
describe.only('suite', () => {
it('task', () => {
assert.equal(Math.sqrt(4), 3)
})
})
describe('another suite', () => {
it('skipped task', () => {
// Task skipped, as tests are running in Only mode
assert.equal(Math.sqrt(4), 3)
})
it.only('task', () => {
// Only this task (and others marked with only) are run
assert.equal(Math.sqrt(4), 2)
})
})
Unimplemented suites and tests
Use .todo
to stub suites and tests that should be implemented
// An entry will be shown in the report for this suite
describe.todo('unimplemented suite')
// An entry will be shown in the report for this task
describe.suite('suite', () => {
it.todo('unimplemented task')
})
TODO
- [ ] Reporter & Better output
- [ ] CLI Help
- [ ] Task filter
- [ ] Mock
- [ ] JSDom
- [ ] Watch
- [ ] Coverage
License
MIT License © 2022 lawliet