Quick Links:
Tutorials:
Docs Links:
A testing tool.
Software Development Engineer in Test
Source: Click here
9 types of API testing 👇👇👇
📌 Smoke Testing
➡️ Purpose: To quickly check if the API is functional.
➡️ Focus: Basic functionality validation.
➡️ Scope: Testing critical paths to ensure that the API is operational without major issues.
📌 Functional Testing
➡️ Purpose: To validate if the API functions as per its documented specifications.
➡️ Focus: Testing specific functionality, input parameters, output results, and business logic.
➡️ Scope: Evaluating the API for various use cases to ensure it meets the defined requirements and expectations.
📌 Integration Testing
➡️ Purpose: To test interactions between multiple APIs or services.
➡️ Focus: Validation of data flow and communication between APIs.
➡️ Scope: Ensuring that APIs can work seamlessly together in an end-to-end scenario, checking if they can exchange data and function collectively.
📌 Regression Testing
➡️ Purpose: To prevent new changes from breaking existing API functionality.
➡️ Focus: Re-running previous test cases to check for any regression or unintended side effects.
➡️ Scope: Verifying that the existing features and behaviors of the API remain intact after making changes or updates.
📌 Load Testing
➡️ Purpose: To assess API performance under expected loads.
➡️ Focus: Measuring response times, throughput, and resource utilization during various load conditions.
➡️ Scope: Testing the scalability of the API and identifying performance bottlenecks or resource limitations.
📌 Stress Testing
➡️ Purpose: To evaluate how the API performs under extreme loads beyond normal usage.
➡️ Focus: Pushing the system to its limits to identify its breaking points.
➡️ Scope: Assessing the robustness and error-handling capabilities of the API under severe stress, helping uncover potential issues.
📌 Security Testing
➡️ Purpose: To identify vulnerabilities and weaknesses in API security.
➡️ Focus: Checking authentication, authorization, data protection, encryption, and other security measures.
➡️ Scope: Protect the API against external threats, such as SQL injection, cross-site scripting (XSS), and unauthorized access.
📌 UI Testing
➡️ Purpose: To validate the interaction between the user interface and APIs.
➡️ Focus: Ensuring that data is displayed correctly in the user interface when accessed through the API.
➡️ Scope: Testing the integration of the API with the front-end components to guarantee a smooth user experience.
📌 Fuzz Testing
➡️ Purpose: To identify vulnerabilities and security issues in the API.
➡️ Focus: Injecting unexpected, invalid, or malicious data to provoke unexpected behavior.
➡️ Scope: Revealing potential vulnerabilities that could be exploited by attackers, such as buffer overflows, injection attacks, and data validation weaknesses.
Source: Click here
Timeouts (in order of my usage):
1. Navigation Timeout
=====================
`config.use.navigationTimeout` in `playwright.config.ts`
(Default = 0 i.e., no timeout)
// USAGE: Increase navigation timeout to support slow systems (applies to: page.goBack(), page.goForward(), page.goto(url[, options]), page.reload(), page.setContent(), page.waitForNavigation())
page.context().setDefaultNavigationTimeout(180_000); // Default = 0 (or value set in `config.use.navigationTimeout` in `playwright.config.ts`)
2. `Test` and `beforeAll/afterAll` timeout
==========================================
`config.timeout` in `playwright.config.ts`
- For test: `test.setTimeout(180_000)` // DEFAULT = 30_000 (or value set in `config.timeout` in `playwright.config.ts`)
- For `beforeAll/afterAll` timeout: `test.setTimeout(180_000)` (this doesn't seem to be settable via `playwright.config.ts`)
3. Default Timeout
==================
`config.use.actionTimeout` in `playwright.config.ts`
(Default = 0 i.e., no timeout)
browserContext.setDefaultTimeout(180_000)
page.setDefaultTimeout(180_000)
locator.click({ timeout: 180_000 })
Other:
Date Last Updated: 9/April/2023
================================
WAIT UNTIL NETWORK IDLE
========================
await page.waitForURL(homeUrl, {
waitUntil: 'networkidle',
});
WAIT FOR SOME TIME ON A PAGE
============================
await page.waitForTimeout(20_000);
TO WAIT FOR A SELECTOR
======================
await page.waitForSelector('main');
TO HELP WITH CHECKING URL AT ANY GIVEN TIME:
============================================
console.log(`Current URL-1: ${page.url()}`);
await page.goto(pagePath, { timeout: 180_000 });
console.log(`Current URL-2: ${page.url()}`);
await page.waitForLoadState('networkidle');
console.log(`Current URL-A: ${page.url()}`);
const expectedUrl = `${baseURL}/app/home`;
await page.waitForNavigation({ url: expectedUrl, timeout: 50_000 });
console.log(`Current URL-B: ${page.url()}`);
TO ENABLE UI FOR browser
========================
+ const browser = await chromium.launch({ headless: false });
Also, you can use --headed flag while running the test so that tests run in browser opened (headed/non-headless mode).
THINGS WHICH FIXED THE ISSUE!
================================
// Improve test timeout to support slow systems.
test.setTimeout(180_000); // Default = 10_000 or value set in file `playwright.config.ts` file i.e,. `config.timeout` value.
test.describe(pagePath, () => {...})
// Make browser ready for testing
setupMockResponses(page);
VIEW COMPLETE HTML OF PAGE
==========================
console.log('html?', await page.content());
console.log('innerHTML?', await page.innerHTML('main'));
console.log('innerText?', await page.innerText('main'));
SET NAVIGATION TIMEOUT FOR A SINGLE NAVIGATION
==============================================
await page.goto(str, {
timeout: 180_000,
waitUntil: 'load', // "load" | | "networkidle" | "commit" | 'domcontentloaded' | undefined
});
playwrignt.config.ts
====================
{
webServer: {
command: process.env.CI
? `npm run serve-build -- -l ${port}`
: `cross-env NODE_ENV=test PORT=${port} npm run start`,
port,
// TIP: Use below to test with `react-scripts` server.
// Note: You would need to change the PORT value to 3000 as well.
// reuseExistingServer: true,
},
}
DEBUGGING TIP
==============
Use below instruction to pause chromium and then test on your own
and without automation. Use either of below options:
1. await page.waitForTimeout(10000 * 1000);
2. page.pause()
npm run test:e2e -- e2e/home.test.ts
Please do it ASAP!
Docs: Click here