maf-test
v1.1.1
Published
Minimal A.F. Testing library
Downloads
1
Readme
maf-test
Minimal And Focused Testing Library
What?
I wanted a test library that:
- Had ZERO dependancies
- Was Small
- Was super simple
- Was essentially just "Describe" and "Test"
- Was completely functional
- Had zero side effects
Why?
I had a dumb idea where i wanted to be able to:
- Write tests
- Have them in a browser worthy file
- Include them as a script
- Have that script run
- That script had no side effects, other than output to the console
Nothing out there really fit that exact niche. A few came close, but not quite. Most test "libraries" out there turn out to be closer to frameworks, with test runners, assertion libraries and test suites all bundled into the core package.
Examples:
import { describe, test } from "maf-test";
const result = describe([
test("This is a test", () => {
...run your test here
}),
test("This is a failing sync test", () => {
throw new Error("This is an Error");
}),
test("This is an async test", () => {
...run your test here...
})
]);
The returned result will be a promise. That promise will resolve with something like this
const result = [
{
name : "This is a test"
result : true
error : null
},
{
name : "This is a failing sync test",
result : false,
error : "This is an Error"
}
{
name : "This is an async test",
result : true,
error : null
}
];
Assertion
This library does not contain any implementations of assertions. It instead, plays on the assumption that any uncaught error, is the result of an assertion. Therefore, you can use a far more wellrounded assertion library than i ever could write, like chai.js.
Chai is my recommendation as it's small, without dependancies and runs anywhere. Not only that, it's well rounded and nice to use.