diff --git a/rules/__tests__/prefer-to-be-null.test.js b/rules/__tests__/prefer-to-be-null.test.js index 9367cd99d..d3fb09319 100644 --- a/rules/__tests__/prefer-to-be-null.test.js +++ b/rules/__tests__/prefer-to-be-null.test.js @@ -18,6 +18,7 @@ ruleTester.run('prefer-to-be-null', rule, { 'expect("a string").toMatchSnapshot(null);', 'expect("a string").not.toMatchSnapshot();', "expect(something).toEqual('a string');", + 'expect(null).toBe', ], invalid: [ diff --git a/rules/__tests__/prefer-to-be-undefined.test.js b/rules/__tests__/prefer-to-be-undefined.test.js index 95415a02f..577f362f1 100644 --- a/rules/__tests__/prefer-to-be-undefined.test.js +++ b/rules/__tests__/prefer-to-be-undefined.test.js @@ -15,6 +15,7 @@ ruleTester.run('prefer-to-be-undefined', rule, { 'expect(something).toEqual(somethingElse)', 'expect(something).not.toBe(somethingElse)', 'expect(something).not.toEqual(somethingElse)', + 'expect(undefined).toBe', ], invalid: [ diff --git a/rules/util.js b/rules/util.js index 9f8861a78..c3141e0fa 100644 --- a/rules/util.js +++ b/rules/util.js @@ -73,9 +73,11 @@ const methodName = node => method(node).name; const methodName2 = node => method2(node).name; -const argument = node => node.parent.parent.arguments[0]; +const argument = node => + node.parent.parent.arguments && node.parent.parent.arguments[0]; -const argument2 = node => node.parent.parent.parent.arguments[0]; +const argument2 = node => + node.parent.parent.parent.arguments && node.parent.parent.parent.arguments[0]; const describeAliases = Object.assign(Object.create(null), { describe: true,