Skip to content

Commit 1cd4c02

Browse files
committed
Tests & FMT
1 parent 77b9b49 commit 1cd4c02

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/rules/prefer-web-first-assertions.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ runRuleTester('prefer-web-first-assertions', rule, {
641641
code: javascript('expect(await foo.allTextContents()).toBe("bar")'),
642642
errors: [{ messageId: 'useWebFirstAssertion' }],
643643
},
644+
{
645+
code: javascript(`
646+
const myText = page.locator('foo li').allTextContents();
647+
expect(myText).toEqual(['Alpha', 'Beta', 'Gamma'])`),
648+
errors: [{ messageId: 'useWebFirstAssertion' }],
649+
},
644650
{
645651
code: javascript('expect(await foo.allTextContents()).not.toBe("bar")'),
646652
errors: [{ messageId: 'useWebFirstAssertion' }],
@@ -1266,6 +1272,7 @@ runRuleTester('prefer-web-first-assertions', rule, {
12661272
{ code: test('let visible = await foo.isVisible()') },
12671273
{ code: test('const value = await bar["inputValue"]()') },
12681274
{ code: test('const isEditable = await baz[`isEditable`]()') },
1275+
{ code: test('const myText = page.locator("foo li").allTextContents()') },
12691276
{
12701277
code: javascript`
12711278
import { expect } from '@playwright/test';
@@ -1332,10 +1339,5 @@ runRuleTester('prefer-web-first-assertions', rule, {
13321339
expect(fooLocatorText).toEqual('foo')
13331340
`),
13341341
},
1335-
{
1336-
code: test(`
1337-
const myText = page.locator('foo li').allTextContents();
1338-
expect(myText).toEqual(['Alpha', 'Beta', 'Gamma'])`),
1339-
},
13401342
],
13411343
})

src/rules/prefer-web-first-assertions.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ export default createRule({
112112
(+!!notModifier ^ +isFalsy && methodConfig.inverse) ||
113113
methodConfig.matcher
114114

115-
// We don't want to provide fix suggestion for some methods.
116-
// In this case, we just report the error and let the user handle it.
117-
if (methodConfig.noFix) {
118-
context.report({
119-
data: { matcher: methodConfig.matcher, method },
120-
messageId: 'useWebFirstAssertion',
121-
node: call.callee.property,
122-
})
123-
return
124-
}
125-
115+
// We don't want to provide fix suggestion for some methods.
116+
// In this case, we just report the error and let the user handle it.
117+
if (methodConfig.noFix) {
118+
context.report({
119+
data: { matcher: methodConfig.matcher, method },
120+
messageId: 'useWebFirstAssertion',
121+
node: call.callee.property,
122+
})
123+
return
124+
}
125+
126126
const { callee } = call
127127
context.report({
128128
data: {

0 commit comments

Comments
 (0)