SheepySean
(Sean Oldfield)
1
Make sure to read this post before raising a thread here:
Then tell us:
-
What language is this for? TypeScript
-
Which rule? S2699
-
Why do you believe it’s a false-positive/false-negative? Tests are validly asserting with Playwright Syntax
-
Are you using
-
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
A minimal repro case as below. Flags S2699 with “Add at least one assertion to this test case.”
import { test } from '@playwright/test';
test.describe('A Test', () => {
test('should be a test', async ({ page }) => {
await test.expect(page.locator('div').first()).toBeVisible();
});
});
Hi @sheepysean,
Thanks for reporting this false positive and for helping us improve this rule!
I was able to reproduce the issue with the code snippet you provided. We’ve created a ticket JS-2089 to track the fix.
In the meantime, an alternative solution that doesn’t raise a False Positive is to import expect from @playwright/test directly like this:
import { test, expect } from '@playwright/test';
test.describe('A Test', () => {
test('should be a test', async ({ page }) => {
await expect(page.locator('div').first()).toBeVisible();
});
});
I’ll work on it asap so it can be included in the next release of SonarJS.
Thanks again for the report.
SheepySean
(Sean Oldfield)
5
Thanks for your reply Erwan! Glad it will get fixed 