@rapidjs.org/testing-unit
v0.1.0
Published
rJS Testing – Unit test suite.
Downloads
7
Readme
rJS Testing UnitTest unit
rJS Testing test suite for unit testing providing the expression symmetrical UnitTest
class.
npx rjs-test unit <tests-path>
Integrated in [
rapidjs-org/testing
](https://github.com/t-ski/rJS Testing)
Test Anatomy
Expressions
.actual(expression: any)
.expected(expression: any) // Identity assertion
Value-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