How to use Playwright Fixtures to improve your testing code

What is Fixture?

For example I created 2 tests, one with page and baseURL fixtures and the other one with browser fixtures.

Improving and creating new fixtures

I created a common-fixture.js, override page fixture to visit my website and use the page then generate another fixture called apiToken to use if I need to make an API request using this authorization.

Using new fixtures

The fixture visits google without any before hooks, then still running the test normally.

Conclusion

--

--

--

27y, someone who likes Japanese culture more than one should. Software Development Engineer In Test at @Avalara IG: @csnoodles Twitch: twitch.tv/xnoodlesx

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introduction to Javascript part-2

Glue between Node.js and Python

CUSTOM ROUTE IN LARAVEL

Our Uniswap Delegation Dashboard Is Coming Along!

STACKS.!

Naming Variables :

ReactJS Tutorial for Beginners -6

How to use Docker with Node.js a step-by-step tutorial (including docker-compose)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Wagner Salustiano

Wagner Salustiano

27y, someone who likes Japanese culture more than one should. Software Development Engineer In Test at @Avalara IG: @csnoodles Twitch: twitch.tv/xnoodlesx

More from Medium

Playwright-Java (Part-2): Component driven pattern

Confirmatory Testing

Real Device Cloud For Native App Testing

Visual Regression Testing in Websites