Added throwUnless and throwUnlessAsync

These are similar to `expect` and `expectAsync` except that they throw
exceptions rather than recording matcher failures as spec/suite failures.
They're intended to support using Jasmine matchers in testing-library's
`waitFor`, and also provide a way to integration-test custom matchers.

These funtions are not equivalent to `expect` and `expectAsync` and should
not be used in situations where you want a matcher failure to reliably fail
the spec. Whether that happens depends on the structure of the surrounding
code. In general, you should only use `throwUnless` when you expect
something (which could be your own code or library code like `waitFor`) to
catch the resulting exception.

Fixes #2003.
Fixes #1980.
This commit is contained in:
Steve Gravrock
2023-07-15 11:01:27 -07:00
parent 59600a1c29
commit e56bd3918b
5 changed files with 305 additions and 1 deletions

View File

@@ -97,7 +97,8 @@
],
"space-before-blocks": "error",
"no-eval": "error",
"no-var": "error"
"no-var": "error",
"no-debugger": "error"
}
},
"browserslist": [