Skip to content

Commit 73e4d06

Browse files
committed
fix: Support custom expect objects created with expect.configure
Fixes #150
1 parent e7b108d commit 73e4d06

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/utils/ast.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export type ExpectType = 'poll' | 'soft' | 'standalone';
123123
export function getExpectType(
124124
node: ESTree.CallExpression
125125
): ExpectType | undefined {
126-
if (isIdentifier(node.callee, 'expect')) {
126+
if (isIdentifier(node.callee, /^expect|Expect$/)) {
127127
return 'standalone';
128128
}
129129

test/spec/missing-playwright-await.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,31 @@ runRuleTester('missing-playwright-await', rule, {
139139
],
140140
output: test('await expect[`poll`](() => foo)[`toBeTruthy`]()'),
141141
},
142+
// expect.configure
143+
{
144+
code: dedent`
145+
test('test', async () => {
146+
const softExpect = expect.configure({ soft: true })
147+
softExpect(foo).toBeChecked()
148+
})
149+
`,
150+
errors: [
151+
{
152+
column: 3,
153+
endColumn: 13,
154+
endLine: 3,
155+
line: 3,
156+
messageId: 'expect',
157+
},
158+
],
159+
only: true,
160+
output: dedent`
161+
test('test', async () => {
162+
const softExpect = expect.configure({ soft: true })
163+
await softExpect(foo).toBeChecked()
164+
})
165+
`,
166+
},
142167
// test.step
143168
{
144169
code: test("test.step('foo', async () => {})"),

0 commit comments

Comments
 (0)