Зміст курсу
Introduction to QA Automation Testing
Introduction to QA Automation Testing
Writing Integration Tests with Selenium & Jest
For writing test cases with Selenium & Jest, we need to make sure that the browser window is correctly initialized before any tests. We can use the beforeAll
block to ensure that the browser window is initialized before the tests start executing:
It's important to define the driver
variable outside of this block to ensure that we can access it from the test blocks.
Once the test cases are done executing, we need to make sure the browser window is closed:
The remainder of the process is very similar to how we would write any other kind of tests, except in this case it would involve the use of methods that control the browser to perform tests. For-example, the following test case registers a new user on our twitter application:
In the above code, the timeout value for this test case is manually set to 10000
or 10 seconds because Selenium test cases can potentially take longer than the default 5000
(5 seconds) timeout.
It is important to note that the test cases must contain at least one assertion, also known as an expect
statement. The success or failure of the test case are decided by the results of the assertions.
Following is the full code of the test script used in the video:
Дякуємо за ваш відгук!