Skip to content

Commit

Permalink
* Provide extra information in case of mismatch when using `tester.eq…
Browse files Browse the repository at this point in the history
…` (`tester.js)

* Change interface of custom reporter (`tester.js`)
  • Loading branch information
ctn-malone committed Apr 2, 2021
1 parent 4ae3c11 commit 5a433b3
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [0.2.2]
* Provide extra information in case of mismatch when using `tester.eq` (`tester.js)
* Change interface of custom reporter (`tester.js`)

## [0.2.1]
* Fix `getScriptName` function (`path.js`)

Expand Down
19 changes: 13 additions & 6 deletions doc/tester.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Expects a condition to be `true`
* **[cond]** (*boolean*) : condition to check
* **[msg]** (*string*) : message to display
* opt (*object*) : options
* opt.actualResult (*any*) : if defined, will be displayed in case of failure
* opt.expectedResult (*any*) : if defined, will be displayed in case of failure
* opt.actualResult (*any*) : if defined, will be displayed in case of failure
* opt.expectedResult (*any*) : if defined, will be displayed in case of failure

<u>Examples</u>

Expand Down Expand Up @@ -108,12 +108,13 @@ await tester.run();

## tester.eq(...)

`tester.eq(a, b)`
`tester.eq(a, b, mismatch)`

Checks whether or not two items are equal (deep object comparison)

* a (*any*) : first item
* b (*any*) : second item
* **[a]** (*any*) : first item
* **[b]** (*any*) : second item
* mismatch (*object*) will be filled with information in case of mismatch

**return** *boolean*

Expand Down Expand Up @@ -226,10 +227,16 @@ Following arguments will be passed to the function
* when triggered from `assert`
* msg (*string*) : assertion message
* actualResult (*any*) : result which triggered the failure (only if `opt.actualResult` was defined)
* expectedResult (*any*) : result which was expected (only if `opt.expectedResult` was defined)
* when triggered from `assertEq`
* msg (*string*) : assertion message
* actualResult (*any*)
* expectedResult (*any*)
* expectedResult (*any*)
* mismatch (*object*)
* mismatch.path (*[string|integer, string|integer, ...]*) : path of the mismatch key (will be empty for a *top-level* value)
* mismatch.types (*[string, string]*) : defined in case of type mismatch
* mismatch.lengths (*[integer, integer]*) : defined in case of length mismatch
* mismatch.values (*[any, any]*) : defined in case of value mismatch
* when triggered from `assertNeq`
* msg (*string*) : assertion message
* unexpectedResult (*any*)
Expand Down
Loading

0 comments on commit 5a433b3

Please sign in to comment.