@rapidjs.org/testing-unit
v0.1.1
Published
rJS Testing – Unit testing suite.
Readme
rJS Testing UnitTest unit
rJS Testing unit testing suite (UnitTest): Test arbitrary units of code based on deep expectation comparisons.
npm i -D @rapidjs.org/testing-unitnpx rjs-testing unit <tests-path>Integrated in
rapidjs-org/testing.
Test Anatomy
Expressions
.actual(expression: any)
.expected(expression: any) // Identity assertionValue-based Assertion
new UnitTest("Computes quotient of positive integers")
.actual(4 / 2)
.expected(2);Error-based Assertion
new UnitTest("Computes quotient of positive integers")
.actual(() => 4 / x)
.error("x is not defined", ReferenceError);Comparison Strategy
Unit tests work on arbitrary values. That being said, the comparison strategy implements soft (==) deep equality:
✅ SUCCESS
.actual({
foo: {
bar: 2
}
})
.expected({
foo: {
bar: "2"
}
})❌ FAILURE
.actual({
foo: {
bar: 2
}
})
.expected({
foo: {
bar: 4
}
}).actual({
foo: {
bar: 2
}
})
.expected({
foo: {
bar: 2
},
baz: 4
})© Thassilo Martin Schiepanski
