Skip to content

Commit 81d002b

Browse files
Merge pull request #311513 from TimShererWithAquent/us543933-10
Freshness Edit: Azure API Management: Test the self-hosted developer portal
2 parents 9fba699 + 20d7477 commit 81d002b

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

articles/api-management/developer-portal-testing.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ titleSuffix: Azure API Management
44
description: Learn how to set up unit tests and end-to-end tests for your self-hosted API Management portal.
55
author: dlepow
66
ms.author: danlep
7-
ms.date: 03/25/2021
7+
ms.date: 02/09/2026
88
ms.service: azure-api-management
99
ms.topic: how-to
10+
#customer intent: As a developer who maintains a self-hosted API Management portal, I need to create unit tests and end-to-end tests to verify the API for ongoing changes.
1011
---
1112

1213
# Test the self-hosted developer portal
@@ -15,21 +16,19 @@ ms.topic: how-to
1516

1617
This article explains how to set up unit tests and end-to-end tests for your [self-hosted portal](developer-portal-self-host.md).
1718

18-
## Unit tests
19+
## Create unit tests
1920

20-
A unit test is an approach to validate small pieces of functionality. It's done in isolation from other parts of the application.
21+
A unit test is an approach to validate small pieces of functionality. A unit test operates in isolation from other parts of the application.
2122

2223
### Example scenario
2324

2425
In this scenario, you're testing a password input control. It only accepts passwords containing at least:
2526

2627
- One letter
27-
2828
- One number
29-
3029
- One special character
3130

32-
So, the test to validate these requirements looks like this:
31+
The test to validate these requirements looks like this:
3332

3433
```typescript
3534
const passwordInput = new PasswordInput();
@@ -41,12 +40,12 @@ passwordInput.value = "password";
4140
expect(passwordInput.isValid).to.equal(false);
4241

4342
passwordInput.value = "p@ssw0rd";
44-
expect(passwordInput.isValid.to.equal(true);
43+
expect(passwordInput.isValid).to.equal(true);
4544
```
4645

4746
### Project structure
4847

49-
It's common to keep a unit test next to the component it's supposed to validate.
48+
It's common to keep a unit test next to the component that it validates.
5049

5150
```console
5251
component.ts
@@ -68,9 +67,9 @@ httpClient.mock()
6867
});
6968
```
7069

71-
## End-to-end tests
70+
## Create end-to-end tests
7271

73-
An end-to-end test executes a particular user scenario taking exact steps that you expect the user to carry out. In a web application like te Azure API Management developer portal, the user scrolls through the content and selects options to achieve certain results.
72+
An end-to-end test runs a particular user scenario taking exact steps that you expect the user to carry out. In a web application like the Azure API Management developer portal, the user scrolls through the content and selects options to achieve certain results.
7473

7574
To replicate user navigation, you can use browser manipulation helper libraries like [Puppeteer](https://github.com/puppeteer/puppeteer). It lets you simulate user actions and automate assumed scenarios. Puppeteer also automatically takes screenshots of pages or components at any stage of the test. Compare them later with previous results to catch deviations and potential regressions.
7675

@@ -79,15 +78,10 @@ To replicate user navigation, you can use browser manipulation helper libraries
7978
In this scenario, you need to validate a user sign-in flow. This scenario would require the following steps:
8079

8180
1. Open browser and navigate to the sign-in page.
82-
8381
1. Enter the email address.
84-
8582
1. Enter the password.
86-
8783
1. Select **Sign-in**.
88-
8984
1. Verify that user got redirected to Home page.
90-
9185
1. Verify that the page includes the **Profile** menu item. It's one of the possible indicators that you successfully signed in.
9286

9387
To run the test automatically, create a script with exactly the same steps:
@@ -115,11 +109,11 @@ expect(profileMenuItem).not.equals(null);
115109
```
116110

117111
> [!NOTE]
118-
> Strings such as "#email", "#password" and "#signin" are CSS-like selectors that identify HTML elements on the page. See the [Selectors Level 3](https://www.w3.org/TR/selectors-3/) W3C specification to learn more.
112+
> Strings such as `#email`, `#password`, and `#signin` are CSS-like selectors that identify HTML elements on the page. For more information, see [Selectors Level 3 W3C specification](https://www.w3.org/TR/selectors-3/).
119113
120114
### UI component maps
121115

122-
User flows often go through the same pages or components. A good example is the main website menu that is present on every page.
116+
User flows often go through the same pages or components. A good example is the main website menu that's present on every page.
123117

124118
Create a UI component map to avoid configuring and updating the same selectors for every test. For example, you could replace steps 2 through 6 in the preceding example with just two lines:
125119

@@ -130,7 +124,7 @@ await signInWidget.signInWithBasic({ email: "...", password: "..." });
130124

131125
### Test configuration
132126

133-
Certain scenarios may require pre-created data or configuration. For example, you may need to automate user sign-in with social media accounts. It's hard to create that data quickly or easily.
127+
Certain scenarios require pre-created data or configuration. For example, you might need to automate user sign-in with social media accounts. It's hard to create that data quickly or easily.
134128

135129
For this purpose, you could add a special configuration file to your test scenario. The test scripts can pick up required data from the file. Depending on the build and test pipeline, the tests can pull the secrets from a named secure store.
136130

@@ -174,7 +168,7 @@ Here's an example of a `validate.config.json` that would be stored in the `src`
174168

175169
### Headless vs normal tests
176170

177-
Modern browsers such as Chrome or Microsoft Edge allows you to run automation in both headless mode and normal mode. The browser operates without a graphical user interface in headless mode. It still carries out the same page and Document Object Model (DOM) manipulations. The browser UI usually isn't needed in delivery pipelines. In that case, running tests in headless mode is a great option.
171+
Modern browsers, such as Chrome or Microsoft Edge, allow you to run automation in both headless mode and normal mode. The browser operates without a graphical user interface in headless mode. It still carries out the same page and Document Object Model (DOM) manipulations. The browser UI usually isn't needed in delivery pipelines. In that case, running tests in headless mode is a great option.
178172

179173
When you develop a test script, it's useful to see what exactly is happening in the browser. That's a good time to use normal mode.
180174

@@ -196,7 +190,7 @@ export const LaunchOptions = {
196190

197191
## Run tests
198192

199-
There are two built-in ways to execute tests in this project:
193+
There are two built-in ways to run tests in this project:
200194

201195
**npm command**
202196

@@ -206,7 +200,7 @@ npm run test
206200

207201
**Test Explorer**
208202

209-
The Test Explorer extension for VS Code (for example, [Mocha Test Explorer](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter)) has a convenient UI and an option to run tests automatically on every change of the source code:
203+
Use a Test Explorer extension for VS Code. For example, [Mocha Test Explorer](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter) has a convenient UI and an option to run tests automatically on every change of the source code:
210204

211205
:::image type="content" source="media/developer-portal-testing/visual-studio-code-test-explorer.png" alt-text="Screenshot of Visual Studio Code Test Explorer":::
212206

@@ -215,5 +209,4 @@ The Test Explorer extension for VS Code (for example, [Mocha Test Explorer](http
215209
Learn more about the developer portal:
216210

217211
- [Azure API Management developer portal overview](api-management-howto-developer-portal.md)
218-
219212
- [Self-host the developer portal](developer-portal-self-host.md)

0 commit comments

Comments
 (0)