From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Test state

Test state

In this lesson, we'll work with an intermediate example and write tests for the same. So the first test we have here is our report module. It has a function which just generates a report. Of course, the data is hardcoded. And then it opens a JSON file and writes the data to the same. we have to create test for this function and make sure it generates the data in a correct format that is it creates the json file and then we can read the data back into a dictionary which will mean that it has generated the data properly the next step is to check whether or not the generated report has two fields which is timestamp and status so let's go ahead and start with our test module now we'll go ahead and first of all import the report module and then we'll start with our tests so i'll define a test function for the report json like this which will test whether or not the report is generated correctly and to do that first of all we'll let the function generate the report then we can go ahead and…

Contents