@@ -12,6 +12,8 @@ const ruleTester = new TSESLint.RuleTester({
1212
1313ruleTester . run ( 'no-standalone-expect' , rule , {
1414 valid : [
15+ 'expect.any(String)' ,
16+ 'expect.extend({})' ,
1517 'describe("a test", () => { it("an it", () => {expect(1).toBe(1); }); });' ,
1618 'describe("a test", () => { it("an it", () => { const func = () => { expect(1).toBe(1); }; }); });' ,
1719 'describe("a test", () => { const func = () => { expect(1).toBe(1); }; });' ,
@@ -65,6 +67,10 @@ ruleTester.run('no-standalone-expect', rule, {
6567 code : 'expect.hasAssertions()' ,
6668 errors : [ { endColumn : 23 , column : 1 , messageId : 'unexpectedExpect' } ] ,
6769 } ,
70+ {
71+ code : 'expect().hasAssertions()' ,
72+ errors : [ { endColumn : 25 , column : 1 , messageId : 'unexpectedExpect' } ] ,
73+ } ,
6874 {
6975 code : dedent `
7076 describe('scenario', () => {
@@ -163,5 +169,14 @@ ruleTester.run('no-standalone-expect', rule, {
163169 parserOptions : { sourceType : 'module' } ,
164170 errors : [ { endColumn : 51 , column : 28 , messageId : 'unexpectedExpect' } ] ,
165171 } ,
172+ {
173+ code : dedent `
174+ import { expect as pleaseExpect } from '@jest/globals';
175+
176+ beforeEach(() => pleaseExpect.hasAssertions());
177+ ` ,
178+ parserOptions : { sourceType : 'module' } ,
179+ errors : [ { endColumn : 46 , column : 18 , messageId : 'unexpectedExpect' } ] ,
180+ } ,
166181 ] ,
167182} ) ;
0 commit comments