Playwright & Azure DevOps – Perfect Microsoft Family!

Being a test enthusiast and an Azure DevOps fanatic, I couldn’t resist writing this article. In this article, we will learn how to integrate Playwright scripts with Azure DevOps.

Pre-requisites

  1. Knowledge of Playwright, NodeJS and Azure DevOps
  2. Working tests using the above tech stack. If you don’t have one, feel free to use this
  3. Azure DevOps free account. Sign up here to get one
  4. Azure Repos to store the codebase

Steps:

  1. Once you create a free account, log in into Azure DevOps.
  2. Create a new project with the details shown below by clicking Create Project button

3. Once your project is created, go to the Pipelines from the Left Menu

4. Now click on Create Pipeline

5. Now select the code repository from which we can use the code. In this case, the code is residing inside the Azure Repos, so we can click on the “Use Classic Editor” link.

6. Configure the Azure Repository details as given below. NOTE: In case you prefer other code repositories, please select the options accordingly.
7. Click Continue. We need to create an Empty Job now.

8. Now, it’s time for us to configure the Job with information like agents, batch executions and triggering test cases. Let’s do them one by one. Firstly, let’s select the Agent Specification to “windows latest

9. Click the ‘+’ icon near Agent job 1 and search for Node. We need to install Node Tool in our agent before we execute our test. Azure has a job that can do this for us. Once searched, click Add.

10. Configuring Node Task. Playwright supports from Node v14 and above. Hence, let’s configure the task to 16.x as given below.

11. Now add another task. This time, add the “Command Line” task. This task will be helpful for us to install npm (Node Package Manager) and the required libraries/node modules for our playwright test code.

Add this to the Script field :

npm install && npx playwright install

Go to Advanced –> Click on the little (i) icon and select the Link. This will enable the working directory for the task.

12. Now that we have successfully configured the Playwright batch file, let’s configure the NPM where we trigger our tests –

Select Custom for Command. Then add the below code in Commands & arguments.

run tests:e2e
Select the Working directory as configured in Step 11.

13. Once all these steps are done, the Job should look something like the below –

14. Once all the configurations are done, it’s time for us to run it. Click on the ‘Save & Queue’ button.

Conclusion

What we have done till now is the Build Pipeline and there is a Release pipeline you can do as well.

Stay tuned & happy testing!


Image Credits: Google.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: