@testspectra/skills 1.1.8-rc.2 → 1.1.8-rc.21
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/LICENSE.md +48 -48
- package/README.md +78 -78
- package/bin/spectra-skills.js +7 -7
- package/dist/index.js +29 -29
- package/dist/skills/fixtures-data/SKILL.md +109 -109
- package/dist/skills/lifecycle-hooks/SKILL.md +114 -114
- package/dist/skills/matchers-and-assertions/SKILL.md +156 -156
- package/dist/skills/network-interception/SKILL.md +115 -115
- package/dist/skills/page-objects-and-selectors/SKILL.md +132 -132
- package/dist/skills/shared-steps-and-actions/SKILL.md +184 -184
- package/dist/skills/spec-and-suite-authoring/SKILL.md +132 -132
- package/dist/skills/workspace-structure/SKILL.md +193 -193
- package/package.json +11 -12
- package/skills/fixtures-data/SKILL.md +109 -109
- package/skills/lifecycle-hooks/SKILL.md +114 -114
- package/skills/matchers-and-assertions/SKILL.md +156 -156
- package/skills/network-interception/SKILL.md +115 -115
- package/skills/page-objects-and-selectors/SKILL.md +132 -132
- package/skills/shared-steps-and-actions/SKILL.md +184 -184
- package/skills/spec-and-suite-authoring/SKILL.md +132 -132
- package/skills/workspace-structure/SKILL.md +193 -193
|
@@ -1,193 +1,193 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: workspace-structure
|
|
3
|
-
description: TestSpectra workspace layout, zero-import ambient type architecture, platform file suffixes (web/android/ios/mobile/common), spectra.config.ts, and the core spectra CLI commands. Use before scaffolding any new TestSpectra project or file so it lands in the right directory with the right suffix.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Skill: TestSpectra Workspace Structure & Zero-Import Architecture
|
|
7
|
-
|
|
8
|
-
Use this skill whenever you scaffold a new TestSpectra workspace, add a new file to an existing
|
|
9
|
-
one, or need to decide where a Page Object / Step / Action / Hook / Fixture belongs.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 1. Core Philosophy: Git-First, Spec-as-Code
|
|
14
|
-
|
|
15
|
-
Every test case, shared step, Page Object, fixture, and config file is a plain TypeScript or
|
|
16
|
-
Markdown file tracked in git — there is no proprietary binary project format. TestSpectra supports
|
|
17
|
-
two workspace paradigms:
|
|
18
|
-
|
|
19
|
-
1. **Default Project Mode** (`spectra init`, single-root repo) — one app, one `spectra.config.ts`.
|
|
20
|
-
2. **Monorepo / Nx Project Mode** (`spectra init --template nx`) — multiple `packages/*` test
|
|
21
|
-
projects sharing a library under `shared/testing` (or a custom path), wired into
|
|
22
|
-
`pnpm-workspace.yaml`.
|
|
23
|
-
|
|
24
|
-
Never guess which mode a repo uses — check for `nx.json` / `pnpm-workspace.yaml` with a
|
|
25
|
-
`packages:` list first.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## 2. Default Workspace Directory Layout
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
my-test-project/
|
|
33
|
-
├── .testspectra/ # Auto-managed. NEVER hand-edit these files.
|
|
34
|
-
│ ├── tsconfig/ # web.json, mobile.json, android.json, ios.json, common.json
|
|
35
|
-
│ ├── types/ # web.d.ts, mobile.d.ts, android.d.ts, ios.d.ts, common.d.ts,
|
|
36
|
-
│ │ # fixtures.d.ts — ambient globals (Spectra, Step, Fixture, POs)
|
|
37
|
-
│ └── reports/ # report.json, network-resources.json, last-run.json
|
|
38
|
-
│
|
|
39
|
-
├── specs/ # Test suites & test cases (Spec-as-Code)
|
|
40
|
-
│ └── <SuiteName>/
|
|
41
|
-
│ ├── suite.md # Suite metadata (id, name, executionOrder, parallel)
|
|
42
|
-
│ ├── hooks/ # Suite-level lifecycle hooks (before/beforeEach/afterEach/after)
|
|
43
|
-
│ └── TC-<NNNN>-<slug>/ # One directory per test case
|
|
44
|
-
│ ├── spec.md # Frontmatter + "## Test Steps" with @step:<name> directives
|
|
45
|
-
│ ├── web.test.ts # and/or android.test.ts / ios.test.ts / mobile.test.ts / common.test.ts
|
|
46
|
-
│
|
|
47
|
-
├── page-objects/ # Page Object Model singletons
|
|
48
|
-
│ └── <PageName>/
|
|
49
|
-
│ ├── web.ts
|
|
50
|
-
│ └── mobile.ts # (or android.ts / ios.ts)
|
|
51
|
-
│
|
|
52
|
-
├── support/
|
|
53
|
-
│ ├── steps/ # High-level reusable business workflows (Step.*)
|
|
54
|
-
│ │ └── <stepName>/
|
|
55
|
-
│ │ ├── step.md
|
|
56
|
-
│ │ ├── web.step.ts
|
|
57
|
-
│ │ └── mobile.step.ts
|
|
58
|
-
│ └── actions/ # Low-level technical utilities (Spectra.<action>())
|
|
59
|
-
│ └── <actionName>/
|
|
60
|
-
│ ├── web.action.ts
|
|
61
|
-
│ └── mobile.action.ts
|
|
62
|
-
│
|
|
63
|
-
├── fixtures/ # JSON/CSV test data, auto-typed under Fixture.*
|
|
64
|
-
│ └── users.json
|
|
65
|
-
│
|
|
66
|
-
├── global-hooks/ # Workspace-wide hooks, run once per Global Batch Run only
|
|
67
|
-
│ ├── before/
|
|
68
|
-
│ └── after/
|
|
69
|
-
│
|
|
70
|
-
├── spectra.config.ts # Single source of truth for execution settings
|
|
71
|
-
├── tsconfig.json # References ./.testspectra/tsconfig.json — do not add "include"
|
|
72
|
-
└── package.json # Has "postinstall": "spectra sync-types"
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
For the Nx/monorepo variant, each `packages/<project>/` is its own self-contained workspace
|
|
76
|
-
(`specs/`, `page-objects/`, `spectra.config.ts`, `package.json`), and a shared library
|
|
77
|
-
(default `shared/testing/`) holds cross-project Page Objects/Steps/Actions/Fixtures. **Never** put
|
|
78
|
-
a `specs/` directory or a `spec.md`/`suite.md` file inside the shared library — the linter rejects
|
|
79
|
-
it (`testspectra/no-specs-in-shared-lib`).
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## 3. Zero-Import Rule (Non-Negotiable)
|
|
84
|
-
|
|
85
|
-
TestSpectra scripts **never** contain a manual `import` statement for framework entities. Page
|
|
86
|
-
Objects, `Step.*`, `Fixture.*`, and the global `Spectra` object are all injected as ambient
|
|
87
|
-
globals via `.testspectra/types/*.d.ts`, which the CLI regenerates automatically (sub-60ms) when
|
|
88
|
-
you add/rename files under `page-objects/`, `support/`, or `fixtures/`.
|
|
89
|
-
|
|
90
|
-
- ❌ `import LoginPage from '../../page-objects/LoginPage';`
|
|
91
|
-
- ✅ Just reference `LoginPage` directly — it resolves globally.
|
|
92
|
-
|
|
93
|
-
Adding an `import` in a `*.test.ts`, `*.step.ts`, `*.action.ts`, `*.hook.ts`, or Page Object file
|
|
94
|
-
triggers linter rule `testspectra/no-manual-import` (error). If a file's types look stale after you
|
|
95
|
-
add a new Page Object/Step/Fixture, run `spectra sync-types` rather than importing manually.
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## 4. Platform File Suffixes
|
|
100
|
-
|
|
101
|
-
| Suffix | Target | Can access |
|
|
102
|
-
| :------------ | :-------------------------- | :-------------------------------------------- |
|
|
103
|
-
| `*.web.*` | Web (Chrome CDP) | web + common |
|
|
104
|
-
| `*.android.*` | Android (native TCP driver) | android + mobile + common |
|
|
105
|
-
| `*.ios.*` | iOS (XCUITest) | ios + mobile + common |
|
|
106
|
-
| `*.mobile.*` | Shared Android & iOS | mobile + common only (no web, no android/ios) |
|
|
107
|
-
| `*.common.*` | Universal (web + mobile) | common only (strictest isolation) |
|
|
108
|
-
|
|
109
|
-
This applies to test scripts (`web.test.ts`), Page Objects (`web.ts`), steps (`web.step.ts`),
|
|
110
|
-
actions (`web.action.ts`), and hooks (`web.hook.ts`). Pick the narrowest suffix that fits — don't
|
|
111
|
-
write a `mobile.test.ts` for something that is actually web-only.
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## 5. `spectra.config.ts`
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import { defineConfig } from '@testspectra/cli';
|
|
119
|
-
|
|
120
|
-
export default defineConfig({
|
|
121
|
-
webConfig: {
|
|
122
|
-
baseUrl: 'http://localhost:5173',
|
|
123
|
-
maxConcurrentSessions: '1',
|
|
124
|
-
headless: true,
|
|
125
|
-
implicitWait: '5000',
|
|
126
|
-
parallelizationMode: 'testcase', // "testcase" | "suite"
|
|
127
|
-
},
|
|
128
|
-
androidConfig: {
|
|
129
|
-
driverServer: 'tcp://127.0.0.1:8200',
|
|
130
|
-
appPackage: 'dev.example.app',
|
|
131
|
-
appActivity: 'dev.example.app.MainActivity',
|
|
132
|
-
noReset: false,
|
|
133
|
-
implicitWait: '10000',
|
|
134
|
-
parallelizationMode: 'suite',
|
|
135
|
-
devices: [{ id: 'emulator-5554', name: 'Pixel 8a Emulator', version: '14.0', systemPort: 8200 }],
|
|
136
|
-
},
|
|
137
|
-
iosConfig: {
|
|
138
|
-
appiumServer: 'http://127.0.0.1:4723',
|
|
139
|
-
automationName: 'XCUITest',
|
|
140
|
-
bundleId: '',
|
|
141
|
-
autoAcceptAlerts: true,
|
|
142
|
-
noReset: false,
|
|
143
|
-
implicitWait: '10000',
|
|
144
|
-
parallelizationMode: 'suite',
|
|
145
|
-
devices: [
|
|
146
|
-
{ id: 'iphone-15-pro', name: 'iPhone 15 Pro Simulator', version: '17.0', udid: 'auto', wdaLocalPort: 8100 },
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
executionConfig: {
|
|
150
|
-
networkMonitoringEnabled: true,
|
|
151
|
-
fastResponseTime: '200',
|
|
152
|
-
normalResponseTime: '1000',
|
|
153
|
-
monitoredDomains: [{ domain: 'api.example.com', enabled: true }],
|
|
154
|
-
environmentVariables: { API_MODE: 'sandbox' },
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Numeric-looking fields (timeouts, ports, session counts) accept either a `number` or a numeric
|
|
160
|
-
`string` — stay consistent with whatever the rest of the file already uses.
|
|
161
|
-
|
|
162
|
-
`executionConfig` notes:
|
|
163
|
-
|
|
164
|
-
- **`monitoredDomains`**: empty/absent = record every domain; non-empty = only requests matching
|
|
165
|
-
an `enabled: true` entry (exact hostname or leading-`*` wildcard) get recorded/streamed to the
|
|
166
|
-
Network panel. `networkMonitoringEnabled: false` disables recording outright regardless of this
|
|
167
|
-
list.
|
|
168
|
-
- **`fastResponseTime`/`normalResponseTime`**: millisecond thresholds the VS Code Network panel
|
|
169
|
-
uses to color each request's Duration cell (fast/normal/slow). No effect on test execution
|
|
170
|
-
itself.
|
|
171
|
-
- **`environmentVariables`**: a flat `Record<string, string>` (not an array, not nested
|
|
172
|
-
key/value pairs) — every key becomes both a typed `Spectra.env.KEY` entry (generated into
|
|
173
|
-
`.testspectra/types/env.d.ts`, autocompleted, zero-import — **prefer this over `process.env`**,
|
|
174
|
-
which is untyped `string | undefined`) and a plain `process.env.KEY` string for code that must
|
|
175
|
-
consume the untyped standard API.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## 6. Core `spectra` CLI Commands
|
|
180
|
-
|
|
181
|
-
| Command | Purpose |
|
|
182
|
-
| :--------------------------------------------------- | :------------------------------------------------------------------------------------------------------ |
|
|
183
|
-
| `spectra init [--template nx]` | Scaffold a new workspace |
|
|
184
|
-
| `spectra sync-types` | Regenerate `.testspectra/types` and `.testspectra/tsconfig` (also runs on `postinstall` and file-watch) |
|
|
185
|
-
| `spectra run [path] -t <web\|mobile\|android\|ios>` | Execute tests |
|
|
186
|
-
| `spectra lint [path] [--strict] [--json]` | Validate `spec.md`/`suite.md` schema + code parity (see the `spec-and-suite-authoring` skill) |
|
|
187
|
-
| `spectra doctor` | Preflight dependency/environment health check |
|
|
188
|
-
| `spectra refactor step\|action\|fixture <old> <new>` | Atomically rename across folder, metadata, and all call sites |
|
|
189
|
-
| `spectra watch` | Background file watcher driving `sync-types` |
|
|
190
|
-
|
|
191
|
-
After scaffolding or renaming any file under `page-objects/`, `support/`, or `fixtures/`, assume
|
|
192
|
-
the ambient types are stale until `sync-types` (or the watcher) has run — don't hand-write
|
|
193
|
-
`.testspectra/types/*.d.ts` yourself.
|
|
1
|
+
---
|
|
2
|
+
name: workspace-structure
|
|
3
|
+
description: TestSpectra workspace layout, zero-import ambient type architecture, platform file suffixes (web/android/ios/mobile/common), spectra.config.ts, and the core spectra CLI commands. Use before scaffolding any new TestSpectra project or file so it lands in the right directory with the right suffix.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: TestSpectra Workspace Structure & Zero-Import Architecture
|
|
7
|
+
|
|
8
|
+
Use this skill whenever you scaffold a new TestSpectra workspace, add a new file to an existing
|
|
9
|
+
one, or need to decide where a Page Object / Step / Action / Hook / Fixture belongs.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Core Philosophy: Git-First, Spec-as-Code
|
|
14
|
+
|
|
15
|
+
Every test case, shared step, Page Object, fixture, and config file is a plain TypeScript or
|
|
16
|
+
Markdown file tracked in git — there is no proprietary binary project format. TestSpectra supports
|
|
17
|
+
two workspace paradigms:
|
|
18
|
+
|
|
19
|
+
1. **Default Project Mode** (`spectra init`, single-root repo) — one app, one `spectra.config.ts`.
|
|
20
|
+
2. **Monorepo / Nx Project Mode** (`spectra init --template nx`) — multiple `packages/*` test
|
|
21
|
+
projects sharing a library under `shared/testing` (or a custom path), wired into
|
|
22
|
+
`pnpm-workspace.yaml`.
|
|
23
|
+
|
|
24
|
+
Never guess which mode a repo uses — check for `nx.json` / `pnpm-workspace.yaml` with a
|
|
25
|
+
`packages:` list first.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. Default Workspace Directory Layout
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
my-test-project/
|
|
33
|
+
├── .testspectra/ # Auto-managed. NEVER hand-edit these files.
|
|
34
|
+
│ ├── tsconfig/ # web.json, mobile.json, android.json, ios.json, common.json
|
|
35
|
+
│ ├── types/ # web.d.ts, mobile.d.ts, android.d.ts, ios.d.ts, common.d.ts,
|
|
36
|
+
│ │ # fixtures.d.ts — ambient globals (Spectra, Step, Fixture, POs)
|
|
37
|
+
│ └── reports/ # report.json, network-resources.json, last-run.json
|
|
38
|
+
│
|
|
39
|
+
├── specs/ # Test suites & test cases (Spec-as-Code)
|
|
40
|
+
│ └── <SuiteName>/
|
|
41
|
+
│ ├── suite.md # Suite metadata (id, name, executionOrder, parallel)
|
|
42
|
+
│ ├── hooks/ # Suite-level lifecycle hooks (before/beforeEach/afterEach/after)
|
|
43
|
+
│ └── TC-<NNNN>-<slug>/ # One directory per test case
|
|
44
|
+
│ ├── spec.md # Frontmatter + "## Test Steps" with @step:<name> directives
|
|
45
|
+
│ ├── web.test.ts # and/or android.test.ts / ios.test.ts / mobile.test.ts / common.test.ts
|
|
46
|
+
│
|
|
47
|
+
├── page-objects/ # Page Object Model singletons
|
|
48
|
+
│ └── <PageName>/
|
|
49
|
+
│ ├── web.ts
|
|
50
|
+
│ └── mobile.ts # (or android.ts / ios.ts)
|
|
51
|
+
│
|
|
52
|
+
├── support/
|
|
53
|
+
│ ├── steps/ # High-level reusable business workflows (Step.*)
|
|
54
|
+
│ │ └── <stepName>/
|
|
55
|
+
│ │ ├── step.md
|
|
56
|
+
│ │ ├── web.step.ts
|
|
57
|
+
│ │ └── mobile.step.ts
|
|
58
|
+
│ └── actions/ # Low-level technical utilities (Spectra.<action>())
|
|
59
|
+
│ └── <actionName>/
|
|
60
|
+
│ ├── web.action.ts
|
|
61
|
+
│ └── mobile.action.ts
|
|
62
|
+
│
|
|
63
|
+
├── fixtures/ # JSON/CSV test data, auto-typed under Fixture.*
|
|
64
|
+
│ └── users.json
|
|
65
|
+
│
|
|
66
|
+
├── global-hooks/ # Workspace-wide hooks, run once per Global Batch Run only
|
|
67
|
+
│ ├── before/
|
|
68
|
+
│ └── after/
|
|
69
|
+
│
|
|
70
|
+
├── spectra.config.ts # Single source of truth for execution settings
|
|
71
|
+
├── tsconfig.json # References ./.testspectra/tsconfig.json — do not add "include"
|
|
72
|
+
└── package.json # Has "postinstall": "spectra sync-types"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For the Nx/monorepo variant, each `packages/<project>/` is its own self-contained workspace
|
|
76
|
+
(`specs/`, `page-objects/`, `spectra.config.ts`, `package.json`), and a shared library
|
|
77
|
+
(default `shared/testing/`) holds cross-project Page Objects/Steps/Actions/Fixtures. **Never** put
|
|
78
|
+
a `specs/` directory or a `spec.md`/`suite.md` file inside the shared library — the linter rejects
|
|
79
|
+
it (`testspectra/no-specs-in-shared-lib`).
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 3. Zero-Import Rule (Non-Negotiable)
|
|
84
|
+
|
|
85
|
+
TestSpectra scripts **never** contain a manual `import` statement for framework entities. Page
|
|
86
|
+
Objects, `Step.*`, `Fixture.*`, and the global `Spectra` object are all injected as ambient
|
|
87
|
+
globals via `.testspectra/types/*.d.ts`, which the CLI regenerates automatically (sub-60ms) when
|
|
88
|
+
you add/rename files under `page-objects/`, `support/`, or `fixtures/`.
|
|
89
|
+
|
|
90
|
+
- ❌ `import LoginPage from '../../page-objects/LoginPage';`
|
|
91
|
+
- ✅ Just reference `LoginPage` directly — it resolves globally.
|
|
92
|
+
|
|
93
|
+
Adding an `import` in a `*.test.ts`, `*.step.ts`, `*.action.ts`, `*.hook.ts`, or Page Object file
|
|
94
|
+
triggers linter rule `testspectra/no-manual-import` (error). If a file's types look stale after you
|
|
95
|
+
add a new Page Object/Step/Fixture, run `spectra sync-types` rather than importing manually.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 4. Platform File Suffixes
|
|
100
|
+
|
|
101
|
+
| Suffix | Target | Can access |
|
|
102
|
+
| :------------ | :-------------------------- | :-------------------------------------------- |
|
|
103
|
+
| `*.web.*` | Web (Chrome CDP) | web + common |
|
|
104
|
+
| `*.android.*` | Android (native TCP driver) | android + mobile + common |
|
|
105
|
+
| `*.ios.*` | iOS (XCUITest) | ios + mobile + common |
|
|
106
|
+
| `*.mobile.*` | Shared Android & iOS | mobile + common only (no web, no android/ios) |
|
|
107
|
+
| `*.common.*` | Universal (web + mobile) | common only (strictest isolation) |
|
|
108
|
+
|
|
109
|
+
This applies to test scripts (`web.test.ts`), Page Objects (`web.ts`), steps (`web.step.ts`),
|
|
110
|
+
actions (`web.action.ts`), and hooks (`web.hook.ts`). Pick the narrowest suffix that fits — don't
|
|
111
|
+
write a `mobile.test.ts` for something that is actually web-only.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 5. `spectra.config.ts`
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { defineConfig } from '@testspectra/cli';
|
|
119
|
+
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
webConfig: {
|
|
122
|
+
baseUrl: 'http://localhost:5173',
|
|
123
|
+
maxConcurrentSessions: '1',
|
|
124
|
+
headless: true,
|
|
125
|
+
implicitWait: '5000',
|
|
126
|
+
parallelizationMode: 'testcase', // "testcase" | "suite"
|
|
127
|
+
},
|
|
128
|
+
androidConfig: {
|
|
129
|
+
driverServer: 'tcp://127.0.0.1:8200',
|
|
130
|
+
appPackage: 'dev.example.app',
|
|
131
|
+
appActivity: 'dev.example.app.MainActivity',
|
|
132
|
+
noReset: false,
|
|
133
|
+
implicitWait: '10000',
|
|
134
|
+
parallelizationMode: 'suite',
|
|
135
|
+
devices: [{ id: 'emulator-5554', name: 'Pixel 8a Emulator', version: '14.0', systemPort: 8200 }],
|
|
136
|
+
},
|
|
137
|
+
iosConfig: {
|
|
138
|
+
appiumServer: 'http://127.0.0.1:4723',
|
|
139
|
+
automationName: 'XCUITest',
|
|
140
|
+
bundleId: '',
|
|
141
|
+
autoAcceptAlerts: true,
|
|
142
|
+
noReset: false,
|
|
143
|
+
implicitWait: '10000',
|
|
144
|
+
parallelizationMode: 'suite',
|
|
145
|
+
devices: [
|
|
146
|
+
{ id: 'iphone-15-pro', name: 'iPhone 15 Pro Simulator', version: '17.0', udid: 'auto', wdaLocalPort: 8100 },
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
executionConfig: {
|
|
150
|
+
networkMonitoringEnabled: true,
|
|
151
|
+
fastResponseTime: '200',
|
|
152
|
+
normalResponseTime: '1000',
|
|
153
|
+
monitoredDomains: [{ domain: 'api.example.com', enabled: true }],
|
|
154
|
+
environmentVariables: { API_MODE: 'sandbox' },
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Numeric-looking fields (timeouts, ports, session counts) accept either a `number` or a numeric
|
|
160
|
+
`string` — stay consistent with whatever the rest of the file already uses.
|
|
161
|
+
|
|
162
|
+
`executionConfig` notes:
|
|
163
|
+
|
|
164
|
+
- **`monitoredDomains`**: empty/absent = record every domain; non-empty = only requests matching
|
|
165
|
+
an `enabled: true` entry (exact hostname or leading-`*` wildcard) get recorded/streamed to the
|
|
166
|
+
Network panel. `networkMonitoringEnabled: false` disables recording outright regardless of this
|
|
167
|
+
list.
|
|
168
|
+
- **`fastResponseTime`/`normalResponseTime`**: millisecond thresholds the VS Code Network panel
|
|
169
|
+
uses to color each request's Duration cell (fast/normal/slow). No effect on test execution
|
|
170
|
+
itself.
|
|
171
|
+
- **`environmentVariables`**: a flat `Record<string, string>` (not an array, not nested
|
|
172
|
+
key/value pairs) — every key becomes both a typed `Spectra.env.KEY` entry (generated into
|
|
173
|
+
`.testspectra/types/env.d.ts`, autocompleted, zero-import — **prefer this over `process.env`**,
|
|
174
|
+
which is untyped `string | undefined`) and a plain `process.env.KEY` string for code that must
|
|
175
|
+
consume the untyped standard API.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 6. Core `spectra` CLI Commands
|
|
180
|
+
|
|
181
|
+
| Command | Purpose |
|
|
182
|
+
| :--------------------------------------------------- | :------------------------------------------------------------------------------------------------------ |
|
|
183
|
+
| `spectra init [--template nx]` | Scaffold a new workspace |
|
|
184
|
+
| `spectra sync-types` | Regenerate `.testspectra/types` and `.testspectra/tsconfig` (also runs on `postinstall` and file-watch) |
|
|
185
|
+
| `spectra run [path] -t <web\|mobile\|android\|ios>` | Execute tests |
|
|
186
|
+
| `spectra lint [path] [--strict] [--json]` | Validate `spec.md`/`suite.md` schema + code parity (see the `spec-and-suite-authoring` skill) |
|
|
187
|
+
| `spectra doctor` | Preflight dependency/environment health check |
|
|
188
|
+
| `spectra refactor step\|action\|fixture <old> <new>` | Atomically rename across folder, metadata, and all call sites |
|
|
189
|
+
| `spectra watch` | Background file watcher driving `sync-types` |
|
|
190
|
+
|
|
191
|
+
After scaffolding or renaming any file under `page-objects/`, `support/`, or `fixtures/`, assume
|
|
192
|
+
the ambient types are stale until `sync-types` (or the watcher) has run — don't hand-write
|
|
193
|
+
`.testspectra/types/*.d.ts` yourself.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/skills",
|
|
3
|
-
"version": "1.1.8-rc.
|
|
3
|
+
"version": "1.1.8-rc.21",
|
|
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",
|
|
@@ -41,19 +41,18 @@
|
|
|
41
41
|
"README.md",
|
|
42
42
|
"LICENSE.md"
|
|
43
43
|
],
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsc && node scripts/copy-skills.js",
|
|
46
|
-
"watch": "tsc -w",
|
|
47
|
-
"typecheck": "tsc --noEmit",
|
|
48
|
-
"prepublishOnly": "npm run build"
|
|
49
|
-
},
|
|
50
44
|
"dependencies": {
|
|
51
|
-
"@clack/prompts": "
|
|
45
|
+
"@clack/prompts": "^1.7.0"
|
|
52
46
|
},
|
|
53
47
|
"devDependencies": {
|
|
54
|
-
"@types/node": "
|
|
55
|
-
"typescript": "
|
|
48
|
+
"@types/node": "^20.14.0",
|
|
49
|
+
"typescript": "^5.6.3"
|
|
56
50
|
},
|
|
57
51
|
"type": "module",
|
|
58
|
-
"license": "SEE LICENSE IN LICENSE.md"
|
|
59
|
-
|
|
52
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc && node scripts/copy-skills.js",
|
|
55
|
+
"watch": "tsc -w",
|
|
56
|
+
"typecheck": "tsc --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: fixtures-data
|
|
3
|
-
description: TestSpectra test data fixtures — JSON files under fixtures/, auto-typed globally under Fixture.* with zero imports, and how to reference/refactor them from test scripts, steps, and hooks. Use whenever a test needs static mock data (credentials, catalog items, payloads, locales).
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Skill: Fixture & Test Data Management
|
|
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.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 1. Directory & Storage
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
workspace-root/
|
|
17
|
-
└── fixtures/
|
|
18
|
-
├── users.json # User roles & credential sets
|
|
19
|
-
├── products.json # Catalog items & SKU metadata
|
|
20
|
-
├── api-payloads.json # Mock response payloads
|
|
21
|
-
└── locales.json # Localization dictionaries
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
```json
|
|
25
|
-
// fixtures/users.json
|
|
26
|
-
{
|
|
27
|
-
"admin": {
|
|
28
|
-
"id": "usr-admin-01",
|
|
29
|
-
"name": "System Administrator",
|
|
30
|
-
"email": "admin@testspectra.dev",
|
|
31
|
-
"password": "Password123!",
|
|
32
|
-
"role": "admin"
|
|
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
|
-
```
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 2. Ambient Typing (Zero Import)
|
|
47
|
-
|
|
48
|
-
The `TypeGenerator` watches `fixtures/` and emits `.testspectra/types/fixtures.d.ts` automatically
|
|
49
|
-
whenever a fixture file is created/updated:
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
declare global {
|
|
53
|
-
namespace Fixture {
|
|
54
|
-
const users: typeof import('../../fixtures/users.json');
|
|
55
|
-
const products: typeof import('../../fixtures/products.json');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Never hand-write this file, and never `import` a fixture JSON file directly — always access it via
|
|
61
|
-
the global `Fixture.<fileBaseName>` namespace, exactly like Page Objects and `Step.*`.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## 3. Usage
|
|
66
|
-
|
|
67
|
-
### In test scripts
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
it('should login with admin credentials from fixture', async () => {
|
|
71
|
-
await Spectra.navigate('/auth/login');
|
|
72
|
-
await LoginPage.emailInput.type(Fixture.users.admin.email, { clearFirst: true });
|
|
73
|
-
await LoginPage.passwordInput.type(Fixture.users.admin.password);
|
|
74
|
-
await LoginPage.submitButton.click();
|
|
75
|
-
|
|
76
|
-
await DashboardPage.welcomeMsg.shouldContainText(Fixture.users.admin.name);
|
|
77
|
-
});
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### In shared steps
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
// support/steps/loginUser/web.step.ts
|
|
84
|
-
export default async function (userType: 'admin' | 'standardUser' = 'standardUser') {
|
|
85
|
-
const user = Fixture.users[userType];
|
|
86
|
-
await Spectra.navigate('/auth/login');
|
|
87
|
-
await LoginPage.emailInput.type(user.email, { clearFirst: true });
|
|
88
|
-
await LoginPage.passwordInput.type(user.password);
|
|
89
|
-
await LoginPage.submitButton.click();
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Fixtures are freely usable inside hooks too (e.g. `global-hooks/before` seeding a DB via `fetch`
|
|
94
|
-
with `Fixture.apiPayloads.seedUser`).
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## 4. Renaming a Fixture
|
|
99
|
-
|
|
100
|
-
Never rename a fixture file by hand. Use:
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
spectra refactor fixture users accounts
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
This renames `fixtures/users.json` → `fixtures/accounts.json`, rewrites every `Fixture.users`
|
|
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.
|
|
1
|
+
---
|
|
2
|
+
name: fixtures-data
|
|
3
|
+
description: TestSpectra test data fixtures — JSON files under fixtures/, auto-typed globally under Fixture.* with zero imports, and how to reference/refactor them from test scripts, steps, and hooks. Use whenever a test needs static mock data (credentials, catalog items, payloads, locales).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Fixture & Test Data Management
|
|
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.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Directory & Storage
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
workspace-root/
|
|
17
|
+
└── fixtures/
|
|
18
|
+
├── users.json # User roles & credential sets
|
|
19
|
+
├── products.json # Catalog items & SKU metadata
|
|
20
|
+
├── api-payloads.json # Mock response payloads
|
|
21
|
+
└── locales.json # Localization dictionaries
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
// fixtures/users.json
|
|
26
|
+
{
|
|
27
|
+
"admin": {
|
|
28
|
+
"id": "usr-admin-01",
|
|
29
|
+
"name": "System Administrator",
|
|
30
|
+
"email": "admin@testspectra.dev",
|
|
31
|
+
"password": "Password123!",
|
|
32
|
+
"role": "admin"
|
|
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
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 2. Ambient Typing (Zero Import)
|
|
47
|
+
|
|
48
|
+
The `TypeGenerator` watches `fixtures/` and emits `.testspectra/types/fixtures.d.ts` automatically
|
|
49
|
+
whenever a fixture file is created/updated:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
declare global {
|
|
53
|
+
namespace Fixture {
|
|
54
|
+
const users: typeof import('../../fixtures/users.json');
|
|
55
|
+
const products: typeof import('../../fixtures/products.json');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Never hand-write this file, and never `import` a fixture JSON file directly — always access it via
|
|
61
|
+
the global `Fixture.<fileBaseName>` namespace, exactly like Page Objects and `Step.*`.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 3. Usage
|
|
66
|
+
|
|
67
|
+
### In test scripts
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
it('should login with admin credentials from fixture', async () => {
|
|
71
|
+
await Spectra.navigate('/auth/login');
|
|
72
|
+
await LoginPage.emailInput.type(Fixture.users.admin.email, { clearFirst: true });
|
|
73
|
+
await LoginPage.passwordInput.type(Fixture.users.admin.password);
|
|
74
|
+
await LoginPage.submitButton.click();
|
|
75
|
+
|
|
76
|
+
await DashboardPage.welcomeMsg.shouldContainText(Fixture.users.admin.name);
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### In shared steps
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// support/steps/loginUser/web.step.ts
|
|
84
|
+
export default async function (userType: 'admin' | 'standardUser' = 'standardUser') {
|
|
85
|
+
const user = Fixture.users[userType];
|
|
86
|
+
await Spectra.navigate('/auth/login');
|
|
87
|
+
await LoginPage.emailInput.type(user.email, { clearFirst: true });
|
|
88
|
+
await LoginPage.passwordInput.type(user.password);
|
|
89
|
+
await LoginPage.submitButton.click();
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Fixtures are freely usable inside hooks too (e.g. `global-hooks/before` seeding a DB via `fetch`
|
|
94
|
+
with `Fixture.apiPayloads.seedUser`).
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 4. Renaming a Fixture
|
|
99
|
+
|
|
100
|
+
Never rename a fixture file by hand. Use:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
spectra refactor fixture users accounts
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This renames `fixtures/users.json` → `fixtures/accounts.json`, rewrites every `Fixture.users`
|
|
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.
|