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
jest-chain throws an error when used with one-line expect (arrow functions).
Description
Please consider the following code:
functionsum(a,b){returna+b;}describe('sum',()=>{it('returns 4 for [1, 3]',()=>expect(sum(1,3)).toBe(4));it('returns -2 for [1, -3]',()=>expect(sum(1,-3)).toBe(-2));it('returns 3 for [0, 3]',()=>expect(sum(0,3)).toBe(3));});
Running this without jest-chain works as expected.
Running this with jest-chain fails with the following error:
Jest: `it` and `test` must return either a Promise or undefined.
at Object.asyncFn (node_modules/jest-jasmine2/build/jasmine_async.js:126:11)
Versions
package version: 0.7.2
node version: v10.4.1
npm version: 6.1.0
Notes
FWIW, I think one-line arrow functions should be supported, as they add a lot of clarity in some cases.
I use the following as a (hopefully temporary) workaround:
// Workaround for https://github.com/mattphillips/jest-chain/issues/1constit2=(message,fn)=>it(message,async(...args)=>fn(...args));describe('sum',()=>{it2('returns 4 for [1, 3]',()=>expect(sum(1,3)).toBe(4));it2('returns -2 for [1, -3]',()=>expect(sum(1,-3)).toBe(-2));it2('returns 3 for [0, 3]',()=>expect(sum(0,3)).toBe(3));});
The text was updated successfully, but these errors were encountered:
Hey @amercier thanks for raising this, I wasn't aware of this error inside of Jest 😄
This one will be super hard to solve in userland and feels like potentially it needs some more thought in Jest's core itself. I've raised an issue (above) in Jest to remove this error so I'll keep this open for now and hopefully we can get this closed off by stopping Jest from throwing when returning something other than a Promise/undefined
Summary
jest-chain
throws an error when used with one-lineexpect
(arrow functions).Description
Please consider the following code:
jest-chain
works as expected.jest-chain
fails with the following error:Versions
package
version:0.7.2
node
version:v10.4.1
npm
version:6.1.0
Notes
The text was updated successfully, but these errors were encountered: