Skip to content

Commit

Permalink
fix: Support custom expect objects created with expect.configure
Browse files Browse the repository at this point in the history
Fixes #150
  • Loading branch information
mskelton committed Jun 27, 2023
1 parent e7b108d commit 73e4d06
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export type ExpectType = 'poll' | 'soft' | 'standalone';
export function getExpectType(
node: ESTree.CallExpression
): ExpectType | undefined {
if (isIdentifier(node.callee, 'expect')) {
if (isIdentifier(node.callee, /^expect|Expect$/)) {
return 'standalone';
}

Expand Down
25 changes: 25 additions & 0 deletions test/spec/missing-playwright-await.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ runRuleTester('missing-playwright-await', rule, {
],
output: test('await expect[`poll`](() => foo)[`toBeTruthy`]()'),
},
// expect.configure
{
code: dedent`
test('test', async () => {
const softExpect = expect.configure({ soft: true })
softExpect(foo).toBeChecked()
})
`,
errors: [
{
column: 3,
endColumn: 13,
endLine: 3,
line: 3,
messageId: 'expect',
},
],
only: true,
output: dedent`
test('test', async () => {
const softExpect = expect.configure({ soft: true })
await softExpect(foo).toBeChecked()
})
`,
},
// test.step
{
code: test("test.step('foo', async () => {})"),
Expand Down

0 comments on commit 73e4d06

Please sign in to comment.