@testspectra/skills 1.1.8-rc.5 → 1.1.8-rc.6

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 CHANGED
@@ -1,48 +1,48 @@
1
- # TestSpectra Commercial Software License Agreement
2
-
3
- Copyright (c) 2026 TestSpectra. All rights reserved.
4
-
5
- IMPORTANT NOTICE: This software is NOT open-source. Although distribution archives,
6
- npm packages, and editor extensions are publicly downloadable, installation,
7
- execution, and use of the Software are strictly conditioned upon obtaining a valid
8
- Commercial License or an authorized Evaluation/Trial License from TestSpectra.
9
-
10
- 1. GRANT OF LICENSE
11
- Subject to payment of applicable license fees or an active authorized evaluation
12
- period, TestSpectra grants you a non-exclusive, non-transferable, revocable license
13
- to install and execute the Software solely for authoring, debugging, and executing
14
- automated software tests.
15
-
16
- 2. LICENSE ACTIVATION & ENFORCEMENT
17
- - Use of the Software requires activation via a valid License Key, authorized CI token,
18
- or active TestSpectra Cloud account.
19
- - Any attempt to circumvent, disable, modify, reverse engineer, or tamper with the
20
- license verification mechanisms, cryptographic signatures, or binary checks is
21
- a material breach of this Agreement and automatically terminates your license.
22
-
23
- 3. RESTRICTIONS
24
- You shall not, and shall not permit any third party to:
25
- - Decompile, disassemble, reverse engineer, or derive source code from the binaries,
26
- compiled scripts, or libraries of the Software.
27
- - Sublicense, sell, rent, lease, distribute, or host the Software as a service for third parties.
28
- - Re-brand, white-label, or package the Software or any of its components as part of a
29
- competing commercial QA, testing, or developer tooling product.
30
- - Modify, alter, or remove any proprietary notices, copyright labels, or license headers.
31
-
32
- 4. INTELLECTUAL PROPERTY
33
- The Software, including its source code, architecture, Rust core engine, algorithms,
34
- matchers, extensions, interfaces, and documentation, represents valuable intellectual
35
- property and trade secrets of TestSpectra.
36
-
37
- 5. TERMINATION
38
- This license is effective until terminated. Your rights under this license will terminate
39
- automatically without notice if you fail to comply with any of its terms, or upon expiration
40
- of your active subscription or trial term. Upon termination, you must cease all use of
41
- the Software and delete all copies in your possession.
42
-
43
- 6. DISCLAIMER OF WARRANTY & LIMITATION OF LIABILITY
44
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
45
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
46
- PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
47
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48
- ARISING FROM THE USE OF OR INABILITY TO USE THE SOFTWARE.
1
+ # TestSpectra Commercial Software License Agreement
2
+
3
+ Copyright (c) 2026 TestSpectra. All rights reserved.
4
+
5
+ IMPORTANT NOTICE: This software is NOT open-source. Although distribution archives,
6
+ npm packages, and editor extensions are publicly downloadable, installation,
7
+ execution, and use of the Software are strictly conditioned upon obtaining a valid
8
+ Commercial License or an authorized Evaluation/Trial License from TestSpectra.
9
+
10
+ 1. GRANT OF LICENSE
11
+ Subject to payment of applicable license fees or an active authorized evaluation
12
+ period, TestSpectra grants you a non-exclusive, non-transferable, revocable license
13
+ to install and execute the Software solely for authoring, debugging, and executing
14
+ automated software tests.
15
+
16
+ 2. LICENSE ACTIVATION & ENFORCEMENT
17
+ - Use of the Software requires activation via a valid License Key, authorized CI token,
18
+ or active TestSpectra Cloud account.
19
+ - Any attempt to circumvent, disable, modify, reverse engineer, or tamper with the
20
+ license verification mechanisms, cryptographic signatures, or binary checks is
21
+ a material breach of this Agreement and automatically terminates your license.
22
+
23
+ 3. RESTRICTIONS
24
+ You shall not, and shall not permit any third party to:
25
+ - Decompile, disassemble, reverse engineer, or derive source code from the binaries,
26
+ compiled scripts, or libraries of the Software.
27
+ - Sublicense, sell, rent, lease, distribute, or host the Software as a service for third parties.
28
+ - Re-brand, white-label, or package the Software or any of its components as part of a
29
+ competing commercial QA, testing, or developer tooling product.
30
+ - Modify, alter, or remove any proprietary notices, copyright labels, or license headers.
31
+
32
+ 4. INTELLECTUAL PROPERTY
33
+ The Software, including its source code, architecture, Rust core engine, algorithms,
34
+ matchers, extensions, interfaces, and documentation, represents valuable intellectual
35
+ property and trade secrets of TestSpectra.
36
+
37
+ 5. TERMINATION
38
+ This license is effective until terminated. Your rights under this license will terminate
39
+ automatically without notice if you fail to comply with any of its terms, or upon expiration
40
+ of your active subscription or trial term. Upon termination, you must cease all use of
41
+ the Software and delete all copies in your possession.
42
+
43
+ 6. DISCLAIMER OF WARRANTY & LIMITATION OF LIABILITY
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
45
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
46
+ PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
47
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48
+ ARISING FROM THE USE OF OR INABILITY TO USE THE SOFTWARE.
package/README.md CHANGED
@@ -1,78 +1,78 @@
1
- # @testspectra/skills
2
-
3
- Modular AI agent skills installer & manager for standardizing **TestSpectra** script authoring —
4
- specs, Page Objects, shared steps, custom actions, lifecycle hooks, fixtures, and the matcher
5
- vocabulary.
6
-
7
- Distributed the same way as [`@testspectra/matchers`](../matchers): as a standalone npm package
8
- with its own CLI, installable independently of the main `@testspectra/cli`. When `@testspectra/cli`
9
- is already installed in a workspace, the exact same commands are also available unified under
10
- `spectra skills` — no separate install required.
11
-
12
- ---
13
-
14
- ## Quick Start
15
-
16
- ```bash
17
- # 1. One-time setup: pick agent(s) + which skills to install, in one guided flow
18
- npx @testspectra/skills init # or: spectra skills init
19
-
20
- # 2. Standalone binary (works with zero other TestSpectra packages installed)
21
- npx @testspectra/skills list
22
- npx @testspectra/skills add
23
- npx @testspectra/skills add workspace-structure spec-and-suite-authoring matchers-and-assertions
24
- npx @testspectra/skills update
25
- npx @testspectra/skills remove network-interception
26
-
27
- # Unified under the main CLI (equivalent — use whichever is already installed)
28
- spectra skills list
29
- spectra skills add
30
- spectra skills add workspace-structure spec-and-suite-authoring matchers-and-assertions
31
- spectra skills update
32
- spectra skills remove network-interception
33
- ```
34
-
35
- `init` is a two-step guided flow:
36
-
37
- 1. **Pick agent(s)** — which AI agent(s) the project uses (Claude Code, OpenCode, Kilo, Universal
38
- `.agents`, or the global Gemini CLI). Saved to `.spectra-skills.json` at the workspace root, so
39
- every later `list`/`add`/`update`/`remove` call reads it automatically — no need to re-detect or
40
- re-specify agents each time. Without `init`, commands fall back to auto-detecting only agent
41
- directories that already exist in the target workspace.
42
- 2. **Pick skills** — a multiselect (all 8 pre-checked) of which skills to install right away for
43
- the agent(s) just selected. Deselect what you don't want, or submit empty to skip installing
44
- anything yet (you can always run `add` later).
45
-
46
- A one-off `--agent <ids>` (or `-a` on `spectra skills`) flag on `list`/`add`/`update`/`remove`
47
- overrides the saved selection for a single invocation.
48
-
49
- ---
50
-
51
- ## Available Skills
52
-
53
- | Skill | Covers |
54
- | :--- | :--- |
55
- | `workspace-structure` | Directory layout, zero-import architecture, file suffixes, `spectra.config.ts`, core CLI commands |
56
- | `spec-and-suite-authoring` | `suite.md` / `spec.md` frontmatter, the paired `*.test.ts` script, every `spectra lint` rule |
57
- | `page-objects-and-selectors` | Page Object pattern (`Spectra.get`/`getAll`), the `~`/`#` selector contract |
58
- | `matchers-and-assertions` | Full element action/assertion/collection matcher and global `Spectra.*` command reference |
59
- | `shared-steps-and-actions` | `Step.*` business workflows vs `support/actions/*` technical utilities |
60
- | `lifecycle-hooks` | `global-hooks/` vs `specs/<suite>/hooks/`, execution order, failure cascade |
61
- | `fixtures-data` | `fixtures/*.json` and the ambient `Fixture.*` namespace |
62
- | `network-interception` | `Spectra.intercept()` mocking, polling, and failure-simulation patterns |
63
-
64
- Each skill is grounded in `docs/v2/` and the reference workspace at `cli/templates/default`, so an
65
- AI coding agent scaffolding TestSpectra scripts produces code that already passes `spectra lint`.
66
-
67
- ---
68
-
69
- ## Features
70
-
71
- - **Multi-Agent, Cross-Platform**: Installs into `.claude/skills`, `.agents/skills`,
72
- `.opencode/skills`, `.kilo/skills`, and the Gemini CLI's global skills directory. `init` lets you
73
- pick explicitly; otherwise it auto-detects whichever the target project/agent already uses.
74
- - **Independent Usage**: Works in any TestSpectra workspace (default or Nx/monorepo template)
75
- without requiring the main `@testspectra/cli` to be installed first.
76
- - **Update-in-Place**: `update` re-installs every currently-installed skill from the package's
77
- current registry, so bumping `@testspectra/skills` and re-running `update` refreshes local
78
- copies.
1
+ # @testspectra/skills
2
+
3
+ Modular AI agent skills installer & manager for standardizing **TestSpectra** script authoring —
4
+ specs, Page Objects, shared steps, custom actions, lifecycle hooks, fixtures, and the matcher
5
+ vocabulary.
6
+
7
+ Distributed the same way as [`@testspectra/matchers`](../matchers): as a standalone npm package
8
+ with its own CLI, installable independently of the main `@testspectra/cli`. When `@testspectra/cli`
9
+ is already installed in a workspace, the exact same commands are also available unified under
10
+ `spectra skills` — no separate install required.
11
+
12
+ ---
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # 1. One-time setup: pick agent(s) + which skills to install, in one guided flow
18
+ npx @testspectra/skills init # or: spectra skills init
19
+
20
+ # 2. Standalone binary (works with zero other TestSpectra packages installed)
21
+ npx @testspectra/skills list
22
+ npx @testspectra/skills add
23
+ npx @testspectra/skills add workspace-structure spec-and-suite-authoring matchers-and-assertions
24
+ npx @testspectra/skills update
25
+ npx @testspectra/skills remove network-interception
26
+
27
+ # Unified under the main CLI (equivalent — use whichever is already installed)
28
+ spectra skills list
29
+ spectra skills add
30
+ spectra skills add workspace-structure spec-and-suite-authoring matchers-and-assertions
31
+ spectra skills update
32
+ spectra skills remove network-interception
33
+ ```
34
+
35
+ `init` is a two-step guided flow:
36
+
37
+ 1. **Pick agent(s)** — which AI agent(s) the project uses (Claude Code, OpenCode, Kilo, Universal
38
+ `.agents`, or the global Gemini CLI). Saved to `.spectra-skills.json` at the workspace root, so
39
+ every later `list`/`add`/`update`/`remove` call reads it automatically — no need to re-detect or
40
+ re-specify agents each time. Without `init`, commands fall back to auto-detecting only agent
41
+ directories that already exist in the target workspace.
42
+ 2. **Pick skills** — a multiselect (all 8 pre-checked) of which skills to install right away for
43
+ the agent(s) just selected. Deselect what you don't want, or submit empty to skip installing
44
+ anything yet (you can always run `add` later).
45
+
46
+ A one-off `--agent <ids>` (or `-a` on `spectra skills`) flag on `list`/`add`/`update`/`remove`
47
+ overrides the saved selection for a single invocation.
48
+
49
+ ---
50
+
51
+ ## Available Skills
52
+
53
+ | Skill | Covers |
54
+ | :--- | :--- |
55
+ | `workspace-structure` | Directory layout, zero-import architecture, file suffixes, `spectra.config.ts`, core CLI commands |
56
+ | `spec-and-suite-authoring` | `suite.md` / `spec.md` frontmatter, the paired `*.test.ts` script, every `spectra lint` rule |
57
+ | `page-objects-and-selectors` | Page Object pattern (`Spectra.get`/`getAll`), the `~`/`#` selector contract |
58
+ | `matchers-and-assertions` | Full element action/assertion/collection matcher and global `Spectra.*` command reference |
59
+ | `shared-steps-and-actions` | `Step.*` business workflows vs `support/actions/*` technical utilities |
60
+ | `lifecycle-hooks` | `global-hooks/` vs `specs/<suite>/hooks/`, execution order, failure cascade |
61
+ | `fixtures-data` | `fixtures/*.json` and the ambient `Fixture.*` namespace |
62
+ | `network-interception` | `Spectra.intercept()` mocking, polling, and failure-simulation patterns |
63
+
64
+ Each skill is grounded in `docs/v2/` and the reference workspace at `cli/templates/default`, so an
65
+ AI coding agent scaffolding TestSpectra scripts produces code that already passes `spectra lint`.
66
+
67
+ ---
68
+
69
+ ## Features
70
+
71
+ - **Multi-Agent, Cross-Platform**: Installs into `.claude/skills`, `.agents/skills`,
72
+ `.opencode/skills`, `.kilo/skills`, and the Gemini CLI's global skills directory. `init` lets you
73
+ pick explicitly; otherwise it auto-detects whichever the target project/agent already uses.
74
+ - **Independent Usage**: Works in any TestSpectra workspace (default or Nx/monorepo template)
75
+ without requiring the main `@testspectra/cli` to be installed first.
76
+ - **Update-in-Place**: `update` re-installs every currently-installed skill from the package's
77
+ current registry, so bumping `@testspectra/skills` and re-running `update` refreshes local
78
+ copies.
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env node
2
- import { runCli } from '../dist/index.js';
3
-
4
- runCli().catch((err) => {
5
- console.error(err);
6
- process.exit(1);
7
- });
1
+ #!/usr/bin/env node
2
+ import { runCli } from '../dist/index.js';
3
+
4
+ runCli().catch((err) => {
5
+ console.error(err);
6
+ process.exit(1);
7
+ });
package/dist/index.js CHANGED
@@ -27,35 +27,35 @@ function getPackageVersion() {
27
27
  return '0.0.0';
28
28
  }
29
29
  }
30
- const HELP_TEXT = `
31
- \x1b[1m\x1b[36m🚀 TestSpectra Skills CLI\x1b[0m
32
- Install, update, and manage modular AI agent skills that standardize TestSpectra script authoring.
33
-
34
- \x1b[1mUsage:\x1b[0m
35
- npx @testspectra/skills [command] [options]
36
- spectra-skills [command] [options]
37
-
38
- \x1b[1mCommands:\x1b[0m
39
- \x1b[36minit\x1b[0m Prompt which AI agent(s) you use and save the choice for future commands
40
- \x1b[36mlist\x1b[0m List all available and installed skills
41
- \x1b[36madd\x1b[0m [skills...] Install specified skills (interactive if none provided)
42
- \x1b[36mupdate\x1b[0m [skills...] Update installed skills to latest versions
43
- \x1b[36mremove\x1b[0m <skills...> Remove specified skills from agent environment
44
-
45
- \x1b[1mOptions:\x1b[0m
46
- --target <dir> Target directory (default: current working directory)
47
- --agent <ids> One-off override: comma-separated agent(s) to target, bypassing the
48
- saved "init" selection and auto-detection. Known ids: ${getKnownAgentIds().join(', ')}
49
- -h, --help Show help message
50
- -v, --version Show version
51
-
52
- \x1b[1mExamples:\x1b[0m
53
- npx @testspectra/skills init
54
- npx @testspectra/skills list
55
- npx @testspectra/skills add workspace-structure
56
- npx @testspectra/skills add spec-and-suite-authoring matchers-and-assertions
57
- npx @testspectra/skills update
58
- npx @testspectra/skills remove network-interception
30
+ const HELP_TEXT = `
31
+ \x1b[1m\x1b[36m🚀 TestSpectra Skills CLI\x1b[0m
32
+ Install, update, and manage modular AI agent skills that standardize TestSpectra script authoring.
33
+
34
+ \x1b[1mUsage:\x1b[0m
35
+ npx @testspectra/skills [command] [options]
36
+ spectra-skills [command] [options]
37
+
38
+ \x1b[1mCommands:\x1b[0m
39
+ \x1b[36minit\x1b[0m Prompt which AI agent(s) you use and save the choice for future commands
40
+ \x1b[36mlist\x1b[0m List all available and installed skills
41
+ \x1b[36madd\x1b[0m [skills...] Install specified skills (interactive if none provided)
42
+ \x1b[36mupdate\x1b[0m [skills...] Update installed skills to latest versions
43
+ \x1b[36mremove\x1b[0m <skills...> Remove specified skills from agent environment
44
+
45
+ \x1b[1mOptions:\x1b[0m
46
+ --target <dir> Target directory (default: current working directory)
47
+ --agent <ids> One-off override: comma-separated agent(s) to target, bypassing the
48
+ saved "init" selection and auto-detection. Known ids: ${getKnownAgentIds().join(', ')}
49
+ -h, --help Show help message
50
+ -v, --version Show version
51
+
52
+ \x1b[1mExamples:\x1b[0m
53
+ npx @testspectra/skills init
54
+ npx @testspectra/skills list
55
+ npx @testspectra/skills add workspace-structure
56
+ npx @testspectra/skills add spec-and-suite-authoring matchers-and-assertions
57
+ npx @testspectra/skills update
58
+ npx @testspectra/skills remove network-interception
59
59
  `;
60
60
  export async function runCli() {
61
61
  const args = process.argv.slice(2);
@@ -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.