Playwright Beginner Tutorial 12 | Annotation & Tags

Опубликовано: 01 Октябрь 2024
на канале: Automation Step by Step
16,738
200

ALL FREE COURSES ► https://automationstepbystep.com/
ASK RAGHAV ► https://bit.ly/2CoJGWf
00:00 Intro
00:32 What are Annotations & Tags
How to use Annotations & Tags in Playwright
Step by Step hands-on demo

Hooks:
beforeAll
beforeEach
afterAll
afterEach

Groups:
describe

Annotations:
only
skip
skip with condition
fail
fixme
slow

Tags:
@smoke
@reg

03:09 will skip the test
test.skip('skip this test', async ({ page }) => {
// This test will be skipped
});


05:20 will mark test as failure
will show error if the test does not fail
test('not yet ready', async ({ page }) => {
test.fail();
});

06:39 test will be aborted
test.fixme('test to be fixed', async ({ page }) => {
});

07:36 marks the test as slow and triples the test timeout
test('slow test', async ({ page }) => {
test.slow();
});

08:21 runs specific tests
test.only('focus this test', async ({ page }) => {
// Run only focused tests in the entire project
});

10:28 Tags
You can tag your tests with tags like
@smoke
@sanity
@fast @slow
and only run the tests that have the certain tag

test('Test full report @smoke, async ({ page }) => {
// ...
});

npx playwright test --grep “@smoke”

Opposite of grep Skip tests with certain tag
npx playwright test --grep-invert “@smoke”

13:54 What are Annotations

Annotations are keywords that contain some logical or conditional functionalities
Can be used with test blocks to control execution of tests as needed
E.g. only, fail, fix, slow

We can apply annotations to a single test or a set of tests

STORIES BY RAGHAV ► https://automationstepbystep.com/stor...
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you

You can support my mission for education by sharing this knowledge and helping as many people as you can

If my work has helped you, consider helping any animal near you, in any way you can

NEVER STOP LEARNING
Raghav Pal