You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functiondoWork(){constdispatch=jest.fn();dispatch(null);dispatch({});dispatch('blah');dispatch(()=>{});returndispatch;}test('passes with exact string',()=>{constdispatch=doWork();expect(dispatch).toBeCalledWith('blah');});test('fails with matcher',()=>{constdispatch=doWork();expect(dispatch).toBeCalledWith(expect.stringContaining('bla'));});
Output:
FAIL./add-test.js●failswithmatcher
TypeError: Cannotreadproperty'includes'ofnullatObject.<anonymous>.test(add-test.js:17:20)atPromise(<anonymous>)
at Promise.resolve.then.el (../../usr/local/share/.config/yarn/global/node_modules/p-map/index.js:42:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:169:7)
✓ passes with exact string (6ms)
✕ fails with matcher (2ms)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 passed, 2 total
Jest should skip the values which don't match and only fail if none match. In my example, the second test should pass because expect.stringMatching('bla') passes on the third call with 'blah'. Basically, the same behaviour as asserting with an exact value.
Tested with
Jest v20.0.4 node v7.4.0 linux/amd64 (repl.it)
Jest v21.2.1 node v8.9.1 macOS X 10.13.1 (locally)
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Repository: https://repl.it/repls/PleasedSubmissiveAfricanbushviper
Output:
Jest should skip the values which don't match and only fail if none match. In my example, the second test should pass because
expect.stringMatching('bla')
passes on the third call with'blah'
. Basically, the same behaviour as asserting with an exact value.Tested with
Jest v20.0.4 node v7.4.0 linux/amd64 (repl.it)
Jest v21.2.1 node v8.9.1 macOS X 10.13.1 (locally)
The text was updated successfully, but these errors were encountered: