You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial/6-api-testing.md
+98-15Lines changed: 98 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,108 @@ this feature shines when used together with web UI testing.
8
8
In this part, we will learn how to use Playwright's API testing features by automating tests
9
9
for [GitHub project boards](https://docs.github.com/en/issues/organizing-your-work-with-project-boards).
10
10
These tests will be more complex than our previous DuckDuckGo search test.
11
-
They will also require additional setup.
11
+
They will make multiple calls to the [GitHub API](https://docs.github.com/en/rest) with authentication.
12
+
The first test will *create* a new project card purely from the GitHub API,
13
+
and the second test will *move* a project card from one column to another.
12
14
13
15
14
16
## API setup
15
17
16
-
17
-
Prerequisites:
18
-
19
-
* GitHub account
20
-
* User project
21
-
* Personal access token
22
-
23
-
24
-
Inputs:
25
-
26
-
* GitHub username
27
-
* GitHub password
28
-
* GitHub access token
29
-
* GitHub user project name
18
+
Before we can develop tests for GitHub project boards,
19
+
we need to set up a few things:
20
+
21
+
1. A GitHub account
22
+
2. A GitHub user project
23
+
3. A GitHub personal access token
24
+
25
+
Pretty much every developer these days already has a GitHub account,
26
+
but not every developer may have set up a project board in GitHub.
27
+
Follow the [user project instructions](https://docs.github.com/en/issues/organizing-your-work-with-project-boards/managing-project-boards/creating-a-project-board#creating-a-user-owned-project-board)
28
+
to create a user project.
29
+
Create a "classic" project and not a *Beta* project.
30
+
Use the "Basic Kanban" template – the project must have at least two columns.
31
+
The project may be public or private,
32
+
but I recommend making it private if you intend to use it only for this tutorial.
33
+
34
+
GitHub API calls require a *personal access token* for authentication.
35
+
GitHub no longer supports "basic" authentication with username and password.
36
+
Follow the [personal access token instructions](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
37
+
to create a personal access token.
38
+
Select the **repo** and **user** permissions.
39
+
Remember to copy and save your token somewhere safe,
40
+
because you won't be able to view it again!
41
+
42
+
The tests also need the following four inputs:
43
+
44
+
1. Your GitHub username
45
+
2. Your GitHub password (for UI login)
46
+
3. Your GitHub personal access token (for API authentication)
47
+
4. Your GitHub user project name
48
+
49
+
Let's set these inputs as environment variables
50
+
and read them into tests using pytest fixtures.
51
+
Environment variables must be set before launching tests.
0 commit comments