0.1.1 • Published 9 months ago

@rapidjs.org/testing-unit v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

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-unit
npx rjs-testing unit <tests-path>

Integrated in rapidjs-org/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);

View More Examples

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

0.1.1

9 months ago

0.1.0

12 months ago