@appliqation/automation-sdk 2.1.10 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/package.json +9 -1
- package/src/playwright/global-teardown.js +42 -0
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ module.exports = defineConfig({
|
|
|
125
125
|
['html'], // HTML report
|
|
126
126
|
|
|
127
127
|
// Appliqation reporter for result submission
|
|
128
|
-
['@appliqation/automation-sdk/playwright', appliqationConfig]
|
|
128
|
+
['@appliqation/automation-sdk/playwright/reporter', appliqationConfig]
|
|
129
129
|
],
|
|
130
130
|
|
|
131
131
|
projects: [
|
|
@@ -410,7 +410,7 @@ your-playwright-project/
|
|
|
410
410
|
│ ├── globalSetup: require.resolve('@appliqation/automation-sdk/playwright/global-setup')
|
|
411
411
|
│ ├── globalTeardown: require.resolve('@appliqation/automation-sdk/playwright/global-teardown')
|
|
412
412
|
│ ├── use: { storageState: '.auth/jwt.json' }
|
|
413
|
-
│ └── reporter: ['@appliqation/automation-sdk/playwright', config]
|
|
413
|
+
│ └── reporter: ['@appliqation/automation-sdk/playwright/reporter', config]
|
|
414
414
|
│
|
|
415
415
|
├── tests/
|
|
416
416
|
│ ├── login.spec.js # YOUR TESTS (Step 4)
|
|
@@ -727,18 +727,18 @@ Connection test: { success: true, message: 'Connected to Appliqation portal' }
|
|
|
727
727
|
|
|
728
728
|
For long-running test suites, use the SDK's custom fixture to automatically refresh JWT tokens:
|
|
729
729
|
|
|
730
|
-
**File:** `
|
|
730
|
+
**File:** `tests/example.spec.js`
|
|
731
731
|
```javascript
|
|
732
|
-
|
|
733
|
-
const {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
732
|
+
// Use the SDK's test fixture instead of Playwright's default
|
|
733
|
+
const { test, expect } = require('@appliqation/automation-sdk/playwright');
|
|
734
|
+
|
|
735
|
+
test.describe('Authenticated Tests', () => {
|
|
736
|
+
test('should have valid JWT throughout test', async ({ page }) => {
|
|
737
|
+
// JWT is automatically refreshed if < 5 minutes remaining
|
|
738
|
+
await page.goto('/dashboard');
|
|
739
|
+
// Your test logic...
|
|
740
|
+
});
|
|
739
741
|
});
|
|
740
|
-
|
|
741
|
-
module.exports = { test };
|
|
742
742
|
```
|
|
743
743
|
|
|
744
744
|
**What it does:**
|
|
@@ -806,7 +806,7 @@ Most commonly used SDK exports:
|
|
|
806
806
|
|
|
807
807
|
**Reporter (for playwright.config.js):**
|
|
808
808
|
```javascript
|
|
809
|
-
['@appliqation/automation-sdk/playwright', config]
|
|
809
|
+
['@appliqation/automation-sdk/playwright/reporter', config]
|
|
810
810
|
```
|
|
811
811
|
|
|
812
812
|
**Global Setup/Teardown:**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appliqation/automation-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "Appliqation Automation SDK with API key authentication, custom run titles, and framework-specific reporters",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"import": "./src/index.js"
|
|
11
11
|
},
|
|
12
12
|
"./playwright": {
|
|
13
|
+
"require": "./src/playwright/index.js",
|
|
14
|
+
"import": "./src/playwright/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./playwright/reporter": {
|
|
13
17
|
"require": "./src/reporters/playwright/index.js",
|
|
14
18
|
"import": "./src/reporters/playwright/index.js"
|
|
15
19
|
},
|
|
@@ -17,6 +21,10 @@
|
|
|
17
21
|
"require": "./src/playwright/global-setup.js",
|
|
18
22
|
"import": "./src/playwright/global-setup.js"
|
|
19
23
|
},
|
|
24
|
+
"./playwright/global-teardown": {
|
|
25
|
+
"require": "./src/playwright/global-teardown.js",
|
|
26
|
+
"import": "./src/playwright/global-teardown.js"
|
|
27
|
+
},
|
|
20
28
|
"./playwright/fixture": {
|
|
21
29
|
"require": "./src/playwright/fixture.js",
|
|
22
30
|
"import": "./src/playwright/fixture.js"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Teardown for Playwright Tests
|
|
3
|
+
*
|
|
4
|
+
* This module performs cleanup operations after all tests have completed.
|
|
5
|
+
* It complements global-setup.js which handles JWT authentication setup.
|
|
6
|
+
*
|
|
7
|
+
* What it does:
|
|
8
|
+
* - Logs completion message
|
|
9
|
+
* - Cleans up environment variables
|
|
10
|
+
* - (Optionally) Removes authentication state files
|
|
11
|
+
*
|
|
12
|
+
* @module playwright/global-teardown
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cleanup after all tests complete
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} config - Playwright config object
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
async function globalTeardown(config) {
|
|
22
|
+
console.log('\n🧹 Global Teardown: Cleaning up test environment...\n');
|
|
23
|
+
|
|
24
|
+
// Clean up JWT token from environment (but keep .auth/jwt.json for debugging)
|
|
25
|
+
if (process.env.APPLIQATION_JWT_TOKEN) {
|
|
26
|
+
delete process.env.APPLIQATION_JWT_TOKEN;
|
|
27
|
+
console.log(' ✓ JWT token removed from environment');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Optional: Uncomment to remove authentication state after tests
|
|
31
|
+
// const fs = require('fs');
|
|
32
|
+
// const path = require('path');
|
|
33
|
+
// const authPath = path.resolve('.auth/jwt.json');
|
|
34
|
+
// if (fs.existsSync(authPath)) {
|
|
35
|
+
// fs.unlinkSync(authPath);
|
|
36
|
+
// console.log(' ✓ Authentication state file removed');
|
|
37
|
+
// }
|
|
38
|
+
|
|
39
|
+
console.log('\n✅ Teardown complete!\n');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = globalTeardown;
|