@testspectra/skills 1.1.11-rc.5 → 1.1.12
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.
|
@@ -1,70 +1,67 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: fixtures-data
|
|
3
|
-
description: TestSpectra test data fixtures — JSON
|
|
3
|
+
description: TestSpectra test data fixtures — JSON, documents, images, and media under fixtures/, auto-typed globally under Fixture.* with zero imports, and how to reference/upload/refactor them from test scripts, steps, and hooks. Use whenever a test needs static mock data (credentials, catalog items, payloads, locales) or binary files (images, PDFs, documents) for file uploads.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Skill: Fixture & Test Data Management
|
|
7
7
|
|
|
8
|
-
Use this skill whenever a test case, shared step, or hook needs static data — user credentials,
|
|
9
|
-
product catalogs, mock API payloads, localization strings.
|
|
8
|
+
Use this skill whenever a test case, shared step, or hook needs static data or binary files — user credentials, product catalogs, mock API payloads, localization strings, images (`.png`, `.jpg`, `.svg`), documents (`.pdf`, `.docx`, `.csv`), or media files.
|
|
10
9
|
|
|
11
10
|
---
|
|
12
11
|
|
|
13
|
-
## 1. Directory &
|
|
12
|
+
## 1. Directory & Supported File Types
|
|
14
13
|
|
|
15
14
|
```
|
|
16
15
|
workspace-root/
|
|
17
16
|
└── fixtures/
|
|
18
|
-
├── users.json
|
|
19
|
-
├── products.json
|
|
20
|
-
├──
|
|
21
|
-
|
|
17
|
+
├── users.json # JSON data (user roles & credential sets)
|
|
18
|
+
├── products.json # JSON data (catalog items & SKU metadata)
|
|
19
|
+
├── apiPayloads.json # JSON data (mock response payloads)
|
|
20
|
+
├── sampleImage.png # Image fixture for avatar & photo uploads
|
|
21
|
+
├── sampleDocument.pdf # Document fixture for PDF/report uploads
|
|
22
|
+
├── exportData.csv # Tabular CSV data fixture
|
|
23
|
+
├── vectorIcon.svg # Vector graphics fixture
|
|
24
|
+
└── sampleVideo.mp4 # Media video fixture
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
"standardUser": {
|
|
35
|
-
"id": "usr-std-02",
|
|
36
|
-
"name": "Jane Doe",
|
|
37
|
-
"email": "jane.doe@testspectra.dev",
|
|
38
|
-
"password": "Password123!",
|
|
39
|
-
"role": "member"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
```
|
|
27
|
+
### Supported File Formats
|
|
28
|
+
|
|
29
|
+
| Category | Extensions | Global `Fixture.*` Type | Runtime Value | Common Use Case |
|
|
30
|
+
| :---------------------- | :--------------------------------------------------------------------------------------- | :------------------------------- | :------------------------------------- | :----------------------------------------------------------------------------- |
|
|
31
|
+
| **Structured JSON** | `.json` | `typeof import('.../file.json')` | Parsed JS `Object` / `Array` | Auth credentials, API response payloads, seed data, localization dictionaries. |
|
|
32
|
+
| **Image Assets** | `.png`, `.jpg`, `.jpeg`, `.svg`, `.webp`, `.gif`, `.ico`, `.bmp` | `string` | File path (E2E) / Data URL (Component) | Avatar uploads, photo attachments, canvas/OCR tests, visual baselines. |
|
|
33
|
+
| **Documents & Text** | `.pdf`, `.csv`, `.tsv`, `.txt`, `.md`, `.xml`, `.html`, `.doc`, `.docx`, `.xls`, `.xlsx` | `string` | File path (E2E) / Data URL (Component) | Document uploads, invoice validation, tabular CSV feeds. |
|
|
34
|
+
| **Media & Audio/Video** | `.mp4`, `.webm`, `.mov`, `.mp3`, `.wav`, `.ogg` | `string` | File path (E2E) / Data URL (Component) | Media player testing, streaming verification, file upload inputs. |
|
|
35
|
+
| **Archives & Binaries** | `.zip`, `.tar`, `.gz`, `.bin`, `.dat` | `string` | File path (E2E) / Data URL (Component) | Compressed archive uploads, binary attachments. |
|
|
43
36
|
|
|
44
37
|
---
|
|
45
38
|
|
|
46
39
|
## 2. Ambient Typing (Zero Import)
|
|
47
40
|
|
|
48
|
-
The `TypeGenerator` watches `fixtures/` and emits `.testspectra/types/fixtures.d.ts` automatically
|
|
49
|
-
whenever a fixture file is created/updated:
|
|
41
|
+
The `TypeGenerator` watches `fixtures/` and emits `.testspectra/types/fixtures.d.ts` automatically whenever a fixture file is created, modified, or removed:
|
|
50
42
|
|
|
51
43
|
```typescript
|
|
52
44
|
declare global {
|
|
53
45
|
namespace Fixture {
|
|
46
|
+
// JSON files provide full object property autocomplete
|
|
54
47
|
const users: typeof import('../../fixtures/users.json');
|
|
55
48
|
const products: typeof import('../../fixtures/products.json');
|
|
49
|
+
|
|
50
|
+
// Non-JSON fixtures are typed as string
|
|
51
|
+
const sampleImage: string;
|
|
52
|
+
const sampleDocument: string;
|
|
53
|
+
const exportData: string;
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
```
|
|
59
57
|
|
|
60
|
-
Never hand-write this file, and never `import` a fixture
|
|
61
|
-
the global `Fixture.<fileBaseName>` namespace, exactly like Page Objects and `Step.*`.
|
|
58
|
+
Never hand-write this file, and never `import` a fixture file directly — always access it via the global `Fixture.<fileBaseName>` namespace, exactly like Page Objects and `Step.*`.
|
|
62
59
|
|
|
63
60
|
---
|
|
64
61
|
|
|
65
|
-
## 3. Usage
|
|
62
|
+
## 3. Usage & Examples
|
|
66
63
|
|
|
67
|
-
###
|
|
64
|
+
### A. Working with JSON Data in Tests
|
|
68
65
|
|
|
69
66
|
```typescript
|
|
70
67
|
it('should login with admin credentials from fixture', async () => {
|
|
@@ -77,7 +74,25 @@ it('should login with admin credentials from fixture', async () => {
|
|
|
77
74
|
});
|
|
78
75
|
```
|
|
79
76
|
|
|
80
|
-
###
|
|
77
|
+
### B. File Uploads with Non-JSON Fixtures
|
|
78
|
+
|
|
79
|
+
In both Component testing and E2E testing, pass non-JSON fixtures directly into `.upload()` or `.setValue()`. Original file names and MIME types are automatically preserved:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
it('should upload image and document fixtures', async () => {
|
|
83
|
+
await Spectra.navigate('/profile');
|
|
84
|
+
|
|
85
|
+
// Upload image fixture (.png)
|
|
86
|
+
await ProfilePage.avatarInput.upload(Fixture.sampleImage);
|
|
87
|
+
await ProfilePage.uploadedAvatarName.shouldContainText('sampleImage');
|
|
88
|
+
|
|
89
|
+
// Upload document fixture (.pdf)
|
|
90
|
+
await ProfilePage.documentInput.upload(Fixture.sampleDocument);
|
|
91
|
+
await ProfilePage.uploadedDocName.shouldContainText('sampleDocument');
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### C. In Shared Steps
|
|
81
96
|
|
|
82
97
|
```typescript
|
|
83
98
|
// support/steps/loginUser/web.step.ts
|
|
@@ -90,8 +105,18 @@ export default async function (userType: 'admin' | 'standardUser' = 'standardUse
|
|
|
90
105
|
}
|
|
91
106
|
```
|
|
92
107
|
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
### D. Mocking with `Spectra.intercept`
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Mock API responses with JSON fixtures
|
|
112
|
+
await Spectra.intercept('GET', '/api/users', Fixture.users);
|
|
113
|
+
|
|
114
|
+
// Mock file downloads with PDF fixtures
|
|
115
|
+
await Spectra.intercept('GET', '/downloads/report.pdf', {
|
|
116
|
+
body: Fixture.sampleDocument,
|
|
117
|
+
headers: { 'Content-Type': 'application/pdf' },
|
|
118
|
+
});
|
|
119
|
+
```
|
|
95
120
|
|
|
96
121
|
---
|
|
97
122
|
|
|
@@ -99,11 +124,8 @@ with `Fixture.apiPayloads.seedUser`).
|
|
|
99
124
|
|
|
100
125
|
Never rename a fixture file by hand. Use:
|
|
101
126
|
|
|
102
|
-
```
|
|
103
|
-
spectra refactor fixture
|
|
127
|
+
```bash
|
|
128
|
+
spectra refactor fixture sampleImage brandLogo
|
|
104
129
|
```
|
|
105
130
|
|
|
106
|
-
This renames `fixtures/
|
|
107
|
-
reference across `specs/**/*.test.ts`, `support/steps/**/*.step.ts`, and `hooks/**` to
|
|
108
|
-
`Fixture.accounts`, and regenerates `.testspectra/types/fixtures.d.ts` immediately with 0
|
|
109
|
-
TypeScript errors.
|
|
131
|
+
This renames `fixtures/sampleImage.png` $\rightarrow$ `fixtures/brandLogo.png`, rewrites every `Fixture.sampleImage` reference across `specs/**/*.test.ts`, `support/steps/**/*.step.ts`, and `hooks/**` to `Fixture.brandLogo`, and regenerates `.testspectra/types/fixtures.d.ts` immediately with 0 TypeScript compilation errors.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/skills",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Installer & manager for modular AI agent skills that standardize TestSpectra script authoring (specs, page objects, steps, actions, hooks, fixtures, matchers)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -1,70 +1,67 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: fixtures-data
|
|
3
|
-
description: TestSpectra test data fixtures — JSON
|
|
3
|
+
description: TestSpectra test data fixtures — JSON, documents, images, and media under fixtures/, auto-typed globally under Fixture.* with zero imports, and how to reference/upload/refactor them from test scripts, steps, and hooks. Use whenever a test needs static mock data (credentials, catalog items, payloads, locales) or binary files (images, PDFs, documents) for file uploads.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Skill: Fixture & Test Data Management
|
|
7
7
|
|
|
8
|
-
Use this skill whenever a test case, shared step, or hook needs static data — user credentials,
|
|
9
|
-
product catalogs, mock API payloads, localization strings.
|
|
8
|
+
Use this skill whenever a test case, shared step, or hook needs static data or binary files — user credentials, product catalogs, mock API payloads, localization strings, images (`.png`, `.jpg`, `.svg`), documents (`.pdf`, `.docx`, `.csv`), or media files.
|
|
10
9
|
|
|
11
10
|
---
|
|
12
11
|
|
|
13
|
-
## 1. Directory &
|
|
12
|
+
## 1. Directory & Supported File Types
|
|
14
13
|
|
|
15
14
|
```
|
|
16
15
|
workspace-root/
|
|
17
16
|
└── fixtures/
|
|
18
|
-
├── users.json
|
|
19
|
-
├── products.json
|
|
20
|
-
├──
|
|
21
|
-
|
|
17
|
+
├── users.json # JSON data (user roles & credential sets)
|
|
18
|
+
├── products.json # JSON data (catalog items & SKU metadata)
|
|
19
|
+
├── apiPayloads.json # JSON data (mock response payloads)
|
|
20
|
+
├── sampleImage.png # Image fixture for avatar & photo uploads
|
|
21
|
+
├── sampleDocument.pdf # Document fixture for PDF/report uploads
|
|
22
|
+
├── exportData.csv # Tabular CSV data fixture
|
|
23
|
+
├── vectorIcon.svg # Vector graphics fixture
|
|
24
|
+
└── sampleVideo.mp4 # Media video fixture
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
"standardUser": {
|
|
35
|
-
"id": "usr-std-02",
|
|
36
|
-
"name": "Jane Doe",
|
|
37
|
-
"email": "jane.doe@testspectra.dev",
|
|
38
|
-
"password": "Password123!",
|
|
39
|
-
"role": "member"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
```
|
|
27
|
+
### Supported File Formats
|
|
28
|
+
|
|
29
|
+
| Category | Extensions | Global `Fixture.*` Type | Runtime Value | Common Use Case |
|
|
30
|
+
| :---------------------- | :--------------------------------------------------------------------------------------- | :------------------------------- | :------------------------------------- | :----------------------------------------------------------------------------- |
|
|
31
|
+
| **Structured JSON** | `.json` | `typeof import('.../file.json')` | Parsed JS `Object` / `Array` | Auth credentials, API response payloads, seed data, localization dictionaries. |
|
|
32
|
+
| **Image Assets** | `.png`, `.jpg`, `.jpeg`, `.svg`, `.webp`, `.gif`, `.ico`, `.bmp` | `string` | File path (E2E) / Data URL (Component) | Avatar uploads, photo attachments, canvas/OCR tests, visual baselines. |
|
|
33
|
+
| **Documents & Text** | `.pdf`, `.csv`, `.tsv`, `.txt`, `.md`, `.xml`, `.html`, `.doc`, `.docx`, `.xls`, `.xlsx` | `string` | File path (E2E) / Data URL (Component) | Document uploads, invoice validation, tabular CSV feeds. |
|
|
34
|
+
| **Media & Audio/Video** | `.mp4`, `.webm`, `.mov`, `.mp3`, `.wav`, `.ogg` | `string` | File path (E2E) / Data URL (Component) | Media player testing, streaming verification, file upload inputs. |
|
|
35
|
+
| **Archives & Binaries** | `.zip`, `.tar`, `.gz`, `.bin`, `.dat` | `string` | File path (E2E) / Data URL (Component) | Compressed archive uploads, binary attachments. |
|
|
43
36
|
|
|
44
37
|
---
|
|
45
38
|
|
|
46
39
|
## 2. Ambient Typing (Zero Import)
|
|
47
40
|
|
|
48
|
-
The `TypeGenerator` watches `fixtures/` and emits `.testspectra/types/fixtures.d.ts` automatically
|
|
49
|
-
whenever a fixture file is created/updated:
|
|
41
|
+
The `TypeGenerator` watches `fixtures/` and emits `.testspectra/types/fixtures.d.ts` automatically whenever a fixture file is created, modified, or removed:
|
|
50
42
|
|
|
51
43
|
```typescript
|
|
52
44
|
declare global {
|
|
53
45
|
namespace Fixture {
|
|
46
|
+
// JSON files provide full object property autocomplete
|
|
54
47
|
const users: typeof import('../../fixtures/users.json');
|
|
55
48
|
const products: typeof import('../../fixtures/products.json');
|
|
49
|
+
|
|
50
|
+
// Non-JSON fixtures are typed as string
|
|
51
|
+
const sampleImage: string;
|
|
52
|
+
const sampleDocument: string;
|
|
53
|
+
const exportData: string;
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
```
|
|
59
57
|
|
|
60
|
-
Never hand-write this file, and never `import` a fixture
|
|
61
|
-
the global `Fixture.<fileBaseName>` namespace, exactly like Page Objects and `Step.*`.
|
|
58
|
+
Never hand-write this file, and never `import` a fixture file directly — always access it via the global `Fixture.<fileBaseName>` namespace, exactly like Page Objects and `Step.*`.
|
|
62
59
|
|
|
63
60
|
---
|
|
64
61
|
|
|
65
|
-
## 3. Usage
|
|
62
|
+
## 3. Usage & Examples
|
|
66
63
|
|
|
67
|
-
###
|
|
64
|
+
### A. Working with JSON Data in Tests
|
|
68
65
|
|
|
69
66
|
```typescript
|
|
70
67
|
it('should login with admin credentials from fixture', async () => {
|
|
@@ -77,7 +74,25 @@ it('should login with admin credentials from fixture', async () => {
|
|
|
77
74
|
});
|
|
78
75
|
```
|
|
79
76
|
|
|
80
|
-
###
|
|
77
|
+
### B. File Uploads with Non-JSON Fixtures
|
|
78
|
+
|
|
79
|
+
In both Component testing and E2E testing, pass non-JSON fixtures directly into `.upload()` or `.setValue()`. Original file names and MIME types are automatically preserved:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
it('should upload image and document fixtures', async () => {
|
|
83
|
+
await Spectra.navigate('/profile');
|
|
84
|
+
|
|
85
|
+
// Upload image fixture (.png)
|
|
86
|
+
await ProfilePage.avatarInput.upload(Fixture.sampleImage);
|
|
87
|
+
await ProfilePage.uploadedAvatarName.shouldContainText('sampleImage');
|
|
88
|
+
|
|
89
|
+
// Upload document fixture (.pdf)
|
|
90
|
+
await ProfilePage.documentInput.upload(Fixture.sampleDocument);
|
|
91
|
+
await ProfilePage.uploadedDocName.shouldContainText('sampleDocument');
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### C. In Shared Steps
|
|
81
96
|
|
|
82
97
|
```typescript
|
|
83
98
|
// support/steps/loginUser/web.step.ts
|
|
@@ -90,8 +105,18 @@ export default async function (userType: 'admin' | 'standardUser' = 'standardUse
|
|
|
90
105
|
}
|
|
91
106
|
```
|
|
92
107
|
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
### D. Mocking with `Spectra.intercept`
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Mock API responses with JSON fixtures
|
|
112
|
+
await Spectra.intercept('GET', '/api/users', Fixture.users);
|
|
113
|
+
|
|
114
|
+
// Mock file downloads with PDF fixtures
|
|
115
|
+
await Spectra.intercept('GET', '/downloads/report.pdf', {
|
|
116
|
+
body: Fixture.sampleDocument,
|
|
117
|
+
headers: { 'Content-Type': 'application/pdf' },
|
|
118
|
+
});
|
|
119
|
+
```
|
|
95
120
|
|
|
96
121
|
---
|
|
97
122
|
|
|
@@ -99,11 +124,8 @@ with `Fixture.apiPayloads.seedUser`).
|
|
|
99
124
|
|
|
100
125
|
Never rename a fixture file by hand. Use:
|
|
101
126
|
|
|
102
|
-
```
|
|
103
|
-
spectra refactor fixture
|
|
127
|
+
```bash
|
|
128
|
+
spectra refactor fixture sampleImage brandLogo
|
|
104
129
|
```
|
|
105
130
|
|
|
106
|
-
This renames `fixtures/
|
|
107
|
-
reference across `specs/**/*.test.ts`, `support/steps/**/*.step.ts`, and `hooks/**` to
|
|
108
|
-
`Fixture.accounts`, and regenerates `.testspectra/types/fixtures.d.ts` immediately with 0
|
|
109
|
-
TypeScript errors.
|
|
131
|
+
This renames `fixtures/sampleImage.png` $\rightarrow$ `fixtures/brandLogo.png`, rewrites every `Fixture.sampleImage` reference across `specs/**/*.test.ts`, `support/steps/**/*.step.ts`, and `hooks/**` to `Fixture.brandLogo`, and regenerates `.testspectra/types/fixtures.d.ts` immediately with 0 TypeScript compilation errors.
|