diff --git a/rules/__tests__/valid-describe.test.js b/rules/__tests__/valid-describe.test.js index 618184afe..0804f3832 100644 --- a/rules/__tests__/valid-describe.test.js +++ b/rules/__tests__/valid-describe.test.js @@ -34,6 +34,11 @@ ruleTester.run('valid-describe', rule, { }) }) `, + ` + describe('foo', () => + test('bar', () => {}) + ) + `, ], invalid: [ { diff --git a/rules/valid-describe.js b/rules/valid-describe.js index 3da198064..4dbadd147 100644 --- a/rules/valid-describe.js +++ b/rules/valid-describe.js @@ -76,14 +76,16 @@ module.exports = { loc: paramsLocation(callbackFunction.params), }); } - callbackFunction.body.body.forEach(node => { - if (node.type === 'ReturnStatement') { - context.report({ - message: 'Unexpected return statement in describe callback', - node, - }); - } - }); + if (callbackFunction.body.type === 'BlockStatement') { + callbackFunction.body.body.forEach(node => { + if (node.type === 'ReturnStatement') { + context.report({ + message: 'Unexpected return statement in describe callback', + node, + }); + } + }); + } } }, };