diff --git a/rules/__tests__/valid-expect-in-promise.test.js b/rules/__tests__/valid-expect-in-promise.test.js index 32e294c61..563222439 100644 --- a/rules/__tests__/valid-expect-in-promise.test.js +++ b/rules/__tests__/valid-expect-in-promise.test.js @@ -182,6 +182,15 @@ ruleTester.run('valid-expect-in-promise', rule, { ], valid: [ + ` + it('it1', () => new Promise((done) => { + test() + .then(() => { + expect(someThing).toEqual(true); + done(); + }); + })); + `, ` it('it1', () => { return somePromise.then(() => { diff --git a/rules/valid-expect-in-promise.js b/rules/valid-expect-in-promise.js index 041282807..dc8ab9b75 100644 --- a/rules/valid-expect-in-promise.js +++ b/rules/valid-expect-in-promise.js @@ -88,6 +88,7 @@ const getTestFunction = node => { const isParentThenOrPromiseReturned = (node, testFunctionBody) => { return ( testFunctionBody.type === 'CallExpression' || + testFunctionBody.type === 'NewExpression' || node.parent.parent.type === 'ReturnStatement' || isPromiseReturnedLater(node, testFunctionBody) || isThenOrCatch(node.parent.parent)