Rayrun
← Back to Discord Forum

If Visual test fails, then remaining all test fails. Any way to continue test without failing ?

pradeep0260posted in #help-playwright
Open in Discord
pradeep0260

Visual comparison- Node.js , If visual test fails, further all test gets failed. Any way to continue execution without fail ?

This thread is trying to answer question "Is there a way to continue execution without fail if a visual test fails in Node.js?"

1 reply
butchmayhew
butchmayhew

Give Soft assertions a try

https://playwright.dev/docs/test-assertions#soft-assertions

The test still show failed... but the rest of the test will run if the assertion is a soft one.

Answer

Sure, you can keep your tests running even if a visual test fails in Node.js with @playwright/test. You can use the test.fail() function to mark tests as "should fail". This is useful when you know a certain feature is broken and you're working on a fix.

Here's how you can do it:

import { test } from '@playwright/test';

test('not yet ready', async ({ page }) => {
  test.fail();
  // Your test code here...
});

In this case, the test won't cause the entire suite to fail. It's marked as a known failure until it's fixed.

You can also conditionally mark a test as "should fail". This is handy when a feature is broken under certain conditions. Here's an example:

import { test } from '@playwright/test';

test('fail in WebKit', async ({ page, browserName }) => {
  test.fail(browserName === 'webkit', 'This feature is not implemented for Mac yet');
  // Your test code here...
});

If the browserName is 'webkit', the test will be marked as "should fail". You can also add a description to explain why it's failing.

Remember, use test.fail() to document known issues and prevent false negatives. This way, you can focus on fixing real failures while keeping track of known issues.

By using these techniques, you can manage your test suite more effectively. Happy testing!

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].