@specter-automation/test 1.0.118 → 1.0.120

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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Runs a group of assertions together and reports every result, instead of
3
+ * stopping at the first failure the way `Promise.all` does.
4
+ *
5
+ * Start the checks BEFORE triggering the action so they are already listening
6
+ * for the engine events the action produces:
7
+ *
8
+ * ```ts
9
+ * await expectAll(
10
+ * enemies.flatMap((enemy, i) => [
11
+ * expect(enemy).toHaveGameplayTag('Status.Stunned'),
12
+ * expect(enemy).toHaveAttributeChange('HealthSet', 'Health', { delta: -100 }),
13
+ * expect(enemy).toHaveMovedFurtherThan(spawnLocations[i], 100),
14
+ * ]),
15
+ * () => steelActor.triggerAbilityWithTarget(steel.abilityCharge, target),
16
+ * );
17
+ * ```
18
+ *
19
+ * If any check fails, throws an `AggregateError` whose message reads
20
+ * "N of M checks passed" followed by each failure. If the action itself throws,
21
+ * the checks are still awaited (so no step keeps running after the test ends)
22
+ * and the action's error is rethrown.
23
+ *
24
+ * @param checks Assertion promises, already started (e.g. `expect(x).toHave…()`).
25
+ * @param action Optional trigger to run after the checks are listening.
26
+ */
27
+ export declare function expectAll(checks: ReadonlyArray<PromiseLike<unknown>>, action?: () => unknown | Promise<unknown>): Promise<void>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expectAll = expectAll;
4
+ /**
5
+ * Runs a group of assertions together and reports every result, instead of
6
+ * stopping at the first failure the way `Promise.all` does.
7
+ *
8
+ * Start the checks BEFORE triggering the action so they are already listening
9
+ * for the engine events the action produces:
10
+ *
11
+ * ```ts
12
+ * await expectAll(
13
+ * enemies.flatMap((enemy, i) => [
14
+ * expect(enemy).toHaveGameplayTag('Status.Stunned'),
15
+ * expect(enemy).toHaveAttributeChange('HealthSet', 'Health', { delta: -100 }),
16
+ * expect(enemy).toHaveMovedFurtherThan(spawnLocations[i], 100),
17
+ * ]),
18
+ * () => steelActor.triggerAbilityWithTarget(steel.abilityCharge, target),
19
+ * );
20
+ * ```
21
+ *
22
+ * If any check fails, throws an `AggregateError` whose message reads
23
+ * "N of M checks passed" followed by each failure. If the action itself throws,
24
+ * the checks are still awaited (so no step keeps running after the test ends)
25
+ * and the action's error is rethrown.
26
+ *
27
+ * @param checks Assertion promises, already started (e.g. `expect(x).toHave…()`).
28
+ * @param action Optional trigger to run after the checks are listening.
29
+ */
30
+ async function expectAll(checks, action) {
31
+ // Attach handlers to every check immediately, so a check that fails while
32
+ // the action is still running is never reported as an unhandled rejection.
33
+ const settled = Promise.allSettled(checks);
34
+ if (action) {
35
+ try {
36
+ await action();
37
+ }
38
+ catch (actionError) {
39
+ await settled;
40
+ throw actionError;
41
+ }
42
+ }
43
+ const results = await settled;
44
+ const failures = results.filter((r) => r.status === 'rejected');
45
+ if (failures.length === 0) {
46
+ return;
47
+ }
48
+ const passed = results.length - failures.length;
49
+ const summary = `${passed} of ${results.length} checks passed`;
50
+ const details = failures
51
+ .map((f, i) => ` ${i + 1}. ${firstLine(f.reason)}`)
52
+ .join('\n');
53
+ const error = new AggregateError(failures.map(f => f.reason), `${summary}\n\nFailed checks:\n${details}`);
54
+ // Point the stack (and Playwright's code frame) at the test's expectAll call, not this file.
55
+ Error.captureStackTrace?.(error, expectAll);
56
+ throw error;
57
+ }
58
+ function firstLine(reason) {
59
+ const text = reason instanceof Error ? reason.message : String(reason);
60
+ // Strip ANSI colour codes that Playwright adds to matcher messages.
61
+ const clean = text.replace(/\u001b\[[0-9;]*m/g, '');
62
+ // Specter matcher messages start with the matcher hint (matcher + locator),
63
+ // and the next line says what went wrong, so keep both.
64
+ const lines = clean.split('\n').map(l => l.trim()).filter(l => l.length > 0);
65
+ return lines.slice(0, 2).join(' — ') || clean.trim();
66
+ }
@@ -23,6 +23,8 @@ export interface FilterOptions {
23
23
  export declare class SpecterLocator<T = any> {
24
24
  pipeline: LocatorStep[];
25
25
  protected transport: SpecterTransport;
26
+ /** Friendly name set with named(), shown in step titles and the in-engine runner. */
27
+ label?: string;
26
28
  constructor(transport: SpecterTransport, initialPipeline?: LocatorStep[]);
27
29
  protected clone(): this;
28
30
  get port(): string;
@@ -49,6 +51,18 @@ export declare class SpecterLocator<T = any> {
49
51
  */
50
52
  all(): Promise<this[]>;
51
53
  count(bHideStep?: boolean): Promise<number>;
54
+ /**
55
+ * Gives this locator a friendly name for step titles, error messages and the
56
+ * in-engine runner, e.g. `enemies[0]` instead of `getByTag('Spawned_c36e0554')`.
57
+ * Returns a copy; locators derived from it later (nth, filter, …) do not inherit the name.
58
+ *
59
+ * ```ts
60
+ * const enemies = spawned.map((enemy, i) => enemy.named(`enemies[${i}]`));
61
+ * ```
62
+ */
63
+ named(label: string): this;
64
+ /** The locator pipeline only, without the friendly name. */
65
+ toSelectorString(): string;
52
66
  toString(): string;
53
67
  /**
54
68
  * The "Generic Bridge": Calls any C++ command and returns the raw data.
@@ -8,6 +8,8 @@ const test_1 = __importDefault(require("@playwright/test"));
8
8
  class SpecterLocator {
9
9
  pipeline = [];
10
10
  transport;
11
+ /** Friendly name set with named(), shown in step titles and the in-engine runner. */
12
+ label;
11
13
  constructor(transport, initialPipeline = []) {
12
14
  this.transport = transport;
13
15
  this.pipeline = initialPipeline;
@@ -183,9 +185,28 @@ class SpecterLocator {
183
185
  const response = await this.evaluate("GetCount", {}, undefined, bHideStep);
184
186
  return response?.data?.count ?? 0;
185
187
  }
186
- toString() {
188
+ /**
189
+ * Gives this locator a friendly name for step titles, error messages and the
190
+ * in-engine runner, e.g. `enemies[0]` instead of `getByTag('Spawned_c36e0554')`.
191
+ * Returns a copy; locators derived from it later (nth, filter, …) do not inherit the name.
192
+ *
193
+ * ```ts
194
+ * const enemies = spawned.map((enemy, i) => enemy.named(`enemies[${i}]`));
195
+ * ```
196
+ */
197
+ named(label) {
198
+ const namedLocator = this.clone();
199
+ namedLocator.label = label;
200
+ return namedLocator;
201
+ }
202
+ /** The locator pipeline only, without the friendly name. */
203
+ toSelectorString() {
187
204
  return this.pipeline.map(step => `${step.action}('${step.value}')`).join(' -> ');
188
205
  }
206
+ toString() {
207
+ const selector = this.toSelectorString();
208
+ return this.label ? `${this.label} (${selector})` : selector;
209
+ }
189
210
  // ==========================================
190
211
  // THE "ENTITY" METHODS
191
212
  // ==========================================
@@ -309,7 +330,9 @@ class SpecterLocator {
309
330
  * Clones the locator and binds it to a different player/client's world connection.
310
331
  */
311
332
  client(world) {
312
- return new this.constructor(world.transport, [...this.pipeline]);
333
+ const bound = new this.constructor(world.transport, [...this.pipeline]);
334
+ bound.label = this.label; // Same actor on another connection keeps its name.
335
+ return bound;
313
336
  }
314
337
  async evaluate(command, payload = {}, context, bHideStep = false) {
315
338
  if (bHideStep) {
@@ -166,6 +166,7 @@ export interface SpawnOptions {
166
166
  rotation?: Rotator;
167
167
  properties?: Record<string, any>;
168
168
  spawnController?: boolean;
169
+ name?: string;
169
170
  }
170
171
  export interface ClickOptions {
171
172
  strategy?: 'hardware' | 'broadcast' | 'function';
@@ -633,6 +633,9 @@ class SpecterWorld {
633
633
  const properties = options?.properties;
634
634
  const spawnController = options?.spawnController;
635
635
  await this.evaluate("SpawnActor", { assetPath, tag, location, rotation, properties, spawnController }, assetName, tag);
636
+ if (options?.name) {
637
+ return this.actorByTag(tag).named(options.name);
638
+ }
636
639
  return this.actorByTag(tag);
637
640
  }
638
641
  // ==========================================
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared contract between the worker-side matcher instrumentation and the
3
+ * SpecterReporter. Keep this file free of runtime imports so the reporter can
4
+ * load it without pulling in Playwright's test runtime or the transport.
5
+ */
6
+ import type { GasMatchers } from '../matchers/gas-matchers';
7
+ import type { ActorMatchers } from '../matchers/actor-matchers';
8
+ import type { LocatorMatchers } from '../matchers/locator-matchers';
9
+ import type { WidgetMatchers } from '../matchers/widget-matchers';
10
+ import type { MaterialMatchers } from '../matchers/material-matchers';
11
+ import type { AiMatchers } from '../matchers/ai-matchers';
12
+ /** Attachment name used to carry a matcher result from the worker to the reporter. Leading "_" hides it in Playwright's reports. */
13
+ export declare const SPECTER_MATCHER_ATTACHMENT = "_specter-matcher";
14
+ /** Structured result of one Specter matcher call. */
15
+ export interface SpecterMatcherReport {
16
+ matcher: string;
17
+ isNot: boolean;
18
+ pass: boolean;
19
+ /** Locator pipeline, e.g. getByTag('Spawned_c36e0554') */
20
+ locator: string;
21
+ /** Friendly name set with locator.named(), e.g. enemies[0] */
22
+ locatorLabel?: string;
23
+ /** Which connection ran the check in multi-client tests, e.g. "Server", "Client 1" */
24
+ client?: string;
25
+ expected?: unknown;
26
+ actual?: unknown;
27
+ }
28
+ export type SpecterMatcherName = keyof GasMatchers | keyof ActorMatchers | keyof LocatorMatchers | keyof WidgetMatchers | keyof MaterialMatchers | keyof AiMatchers;
29
+ /**
30
+ * Every Specter matcher. The compile-time check below fails the build if a
31
+ * matcher is added to one of the matcher interfaces but not to this list.
32
+ */
33
+ export declare const SPECTER_MATCHER_NAMES: readonly ["toHaveAttributeValue", "toHaveAttributeChange", "toHaveGameplayTag", "toHaveGameplayEffect", "toHaveAppliedGameplayEffect", "toHaveGameplayAbility", "toHaveAbilityCooldown", "toHaveGameplayEffectStackCount", "toHaveGameplayEffectLevel", "toHaveAttributeBaseValue", "toBeExecutingAbility", "toHaveActivatedAbility", "toHaveGameplayTagCount", "toHaveAnyGameplayTags", "toHaveAllGameplayTags", "toHaveMovedFurtherThan", "toHaveLocation", "toHaveInputMappingContext", "toHaveInputActionValue", "toHavePlayerScore", "toBeNiagaraActive", "toHaveNiagaraAsset", "toBeAudioPlaying", "toHaveSoundAsset", "toBePhysicsSimulating", "toBePhysicsAsleep", "toHaveVelocity", "toHaveCameraFOV", "toBeCameraShaking", "toHaveCameraViewTarget", "toBeAINavigating", "toHaveTeamId", "toBeHostileTowards", "toBePossessed", "toBePlayerControlled", "toBeLocallyControlled", "toHaveController", "toBeFalling", "toBeSwimming", "toBeFlying", "toBeCrouching", "toBeMovingOnGround", "toHaveMovementMode", "toBeVisible", "toHavePropertyValue", "toBeInViewport", "toBeDestroyed", "toHaveCount", "toHaveText", "toHaveValue", "toContainText", "toBeEnabled", "toHaveMaterialScalarParameter", "toHaveMaterialVectorParameter", "toHaveMaterial", "toBeDynamicMaterial", "toHaveMaterialTextureParameter", "toHaveBlackboardValue", "toHaveAIState", "toBeMovingTowards", "toBeMovingAwayFrom", "toBeWithinDistance", "toBeFollowing", "toHaveLineOfSightTo", "toBeRunningBehaviorTree"];
34
+ export declare function isSpecterMatcher(name: string): boolean;
35
+ /**
36
+ * Parses Playwright's expect step title, e.g. `Expect "soft not toHaveGameplayTag"`.
37
+ * Returns null for titles that are not a Specter matcher (built-ins, custom messages).
38
+ */
39
+ export declare function parseSpecterExpectTitle(title: string): {
40
+ matcher: string;
41
+ isNot: boolean;
42
+ } | null;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SPECTER_MATCHER_NAMES = exports.SPECTER_MATCHER_ATTACHMENT = void 0;
4
+ exports.isSpecterMatcher = isSpecterMatcher;
5
+ exports.parseSpecterExpectTitle = parseSpecterExpectTitle;
6
+ /** Attachment name used to carry a matcher result from the worker to the reporter. Leading "_" hides it in Playwright's reports. */
7
+ exports.SPECTER_MATCHER_ATTACHMENT = '_specter-matcher';
8
+ /**
9
+ * Every Specter matcher. The compile-time check below fails the build if a
10
+ * matcher is added to one of the matcher interfaces but not to this list.
11
+ */
12
+ exports.SPECTER_MATCHER_NAMES = [
13
+ // gas-matchers
14
+ 'toHaveAttributeValue', 'toHaveAttributeChange', 'toHaveGameplayTag', 'toHaveGameplayEffect',
15
+ 'toHaveAppliedGameplayEffect', 'toHaveGameplayAbility', 'toHaveAbilityCooldown',
16
+ 'toHaveGameplayEffectStackCount', 'toHaveGameplayEffectLevel', 'toHaveAttributeBaseValue',
17
+ 'toBeExecutingAbility', 'toHaveActivatedAbility', 'toHaveGameplayTagCount',
18
+ 'toHaveAnyGameplayTags', 'toHaveAllGameplayTags',
19
+ // actor-matchers
20
+ 'toHaveMovedFurtherThan', 'toHaveLocation', 'toHaveInputMappingContext', 'toHaveInputActionValue',
21
+ 'toHavePlayerScore', 'toBeNiagaraActive', 'toHaveNiagaraAsset', 'toBeAudioPlaying', 'toHaveSoundAsset',
22
+ 'toBePhysicsSimulating', 'toBePhysicsAsleep', 'toHaveVelocity', 'toHaveCameraFOV', 'toBeCameraShaking',
23
+ 'toHaveCameraViewTarget', 'toBeAINavigating', 'toHaveTeamId', 'toBeHostileTowards', 'toBePossessed',
24
+ 'toBePlayerControlled', 'toBeLocallyControlled', 'toHaveController', 'toBeFalling', 'toBeSwimming',
25
+ 'toBeFlying', 'toBeCrouching', 'toBeMovingOnGround', 'toHaveMovementMode',
26
+ // locator-matchers
27
+ 'toBeVisible', 'toHavePropertyValue', 'toBeInViewport', 'toBeDestroyed', 'toHaveCount',
28
+ // widget-matchers
29
+ 'toHaveText', 'toHaveValue', 'toContainText', 'toBeEnabled',
30
+ // material-matchers
31
+ 'toHaveMaterialScalarParameter', 'toHaveMaterialVectorParameter', 'toHaveMaterial',
32
+ 'toBeDynamicMaterial', 'toHaveMaterialTextureParameter',
33
+ // ai-matchers
34
+ 'toHaveBlackboardValue', 'toHaveAIState', 'toBeMovingTowards', 'toBeMovingAwayFrom',
35
+ 'toBeWithinDistance', 'toBeFollowing', 'toHaveLineOfSightTo', 'toBeRunningBehaviorTree',
36
+ ];
37
+ // If this line errors, add the names shown in the error to SPECTER_MATCHER_NAMES.
38
+ const _allMatchersListed = true;
39
+ void _allMatchersListed;
40
+ const SPECTER_MATCHER_SET = new Set(exports.SPECTER_MATCHER_NAMES);
41
+ function isSpecterMatcher(name) {
42
+ return SPECTER_MATCHER_SET.has(name);
43
+ }
44
+ /**
45
+ * Parses Playwright's expect step title, e.g. `Expect "soft not toHaveGameplayTag"`.
46
+ * Returns null for titles that are not a Specter matcher (built-ins, custom messages).
47
+ */
48
+ function parseSpecterExpectTitle(title) {
49
+ const match = title.match(/^Expect "(?:poll )?(?:soft )?(not )?([A-Za-z]+)"$/);
50
+ if (!match || !isSpecterMatcher(match[2])) {
51
+ return null;
52
+ }
53
+ return { matcher: match[2], isNot: !!match[1] };
54
+ }
@@ -5,12 +5,17 @@ export default class SpecterReporter implements Reporter {
5
5
  private queue;
6
6
  private testStepCounters;
7
7
  private stepIdMap;
8
+ /** Playwright's outer `Expect "<matcher>"` steps for Specter matchers. They are shown under their wrapper step's name. */
9
+ private specterExpectSteps;
8
10
  constructor();
9
11
  private connect;
10
12
  private send;
11
13
  onBegin(config: FullConfig, suite: Suite): void;
12
14
  onTestBegin(test: TestCase): void;
13
15
  private isNestedExpect;
16
+ /** The step opened by instrumentMatchers directly under a Specter expect step. */
17
+ private isSpecterWrapper;
18
+ private readMatcherReport;
14
19
  private getParentStepName;
15
20
  onStepBegin(test: TestCase, result: TestResult, step: TestStep): void;
16
21
  private customStepDurations;
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const ws_1 = __importDefault(require("ws"));
40
40
  const fs = __importStar(require("fs"));
41
+ const specter_matcher_report_1 = require("./specter-matcher-report");
41
42
  function extractLocatorFromExpectTitle(title) {
42
43
  if (!title.startsWith('expect('))
43
44
  return '';
@@ -55,12 +56,47 @@ function extractLocatorFromExpectTitle(title) {
55
56
  }
56
57
  return '';
57
58
  }
59
+ /**
60
+ * Pulls the locator out of a Specter matcher step title:
61
+ * `[Server] toHaveGameplayTag('Status.Stunned') @ enemies[0] (getByTag('Spawned_c36e0554'))`
62
+ */
63
+ function extractLocatorFromMatcherTitle(title) {
64
+ const afterArgs = title.indexOf(') @ ');
65
+ if (afterArgs !== -1) {
66
+ return title.substring(afterArgs + 4).trim();
67
+ }
68
+ const at = title.lastIndexOf(' @ ');
69
+ if (at !== -1) {
70
+ return title.substring(at + 3).trim();
71
+ }
72
+ return extractLocatorFromExpectTitle(title.replace(/^\[[^\]]*\]\s*/, ''));
73
+ }
74
+ /** Short, display-ready text for the runner. Kept under 300 chars like errorMessage, to stay well within Unreal's FName/FString UI limits. */
75
+ function toDisplayText(value) {
76
+ if (value === undefined)
77
+ return '';
78
+ let text;
79
+ if (typeof value === 'string') {
80
+ text = value;
81
+ }
82
+ else {
83
+ try {
84
+ text = JSON.stringify(value);
85
+ }
86
+ catch {
87
+ text = String(value);
88
+ }
89
+ }
90
+ return text.length > 300 ? text.substring(0, 297) + '...' : text;
91
+ }
58
92
  class SpecterReporter {
59
93
  ws = null;
60
94
  isConnected = false;
61
95
  queue = [];
62
96
  testStepCounters = new Map();
63
97
  stepIdMap = new WeakMap();
98
+ /** Playwright's outer `Expect "<matcher>"` steps for Specter matchers. They are shown under their wrapper step's name. */
99
+ specterExpectSteps = new WeakSet();
64
100
  constructor() {
65
101
  this.connect();
66
102
  }
@@ -122,6 +158,21 @@ class SpecterReporter {
122
158
  }
123
159
  return false;
124
160
  }
161
+ /** The step opened by instrumentMatchers directly under a Specter expect step. */
162
+ isSpecterWrapper(step) {
163
+ return step.category === 'test.step' && !!step.parent && this.specterExpectSteps.has(step.parent);
164
+ }
165
+ readMatcherReport(step) {
166
+ const attachment = step.attachments?.find(a => a.name === specter_matcher_report_1.SPECTER_MATCHER_ATTACHMENT && a.body);
167
+ if (!attachment?.body)
168
+ return undefined;
169
+ try {
170
+ return JSON.parse(attachment.body.toString('utf-8'));
171
+ }
172
+ catch {
173
+ return undefined;
174
+ }
175
+ }
125
176
  getParentStepName(step) {
126
177
  let current = step.parent;
127
178
  // Categories that are allowed to act as "Parents" in your UI
@@ -143,60 +194,32 @@ class SpecterReporter {
143
194
  }
144
195
  onStepBegin(test, result, step) {
145
196
  console.log(`[REPORTER DEBUG] Step Begin: "${step.title}" | Category: "${step.category}" | Parent: "${step.parent ? step.parent.title : 'None'}" ("${step.parent ? step.parent.category : ''}")`);
146
- const customMatchers = [
147
- 'Expect "toBeVisible"',
148
- 'Expect "toHavePropertyValue"',
149
- 'Expect "toHaveAttributeValue"',
150
- 'Expect "toHaveGameplayTag"',
151
- 'Expect "toHaveGameplayEffect"'
152
- ];
153
- // 1. Ignore the outer Playwright-generated expect steps for custom matchers
154
- if (step.category === 'expect' && customMatchers.includes(step.title)) {
197
+ // 1. Playwright's outer expect step for a Specter matcher: announced by its wrapper step below,
198
+ // which carries the locator in its title.
199
+ if (step.category === 'expect' && (0, specter_matcher_report_1.parseSpecterExpectTitle)(step.title)) {
200
+ this.specterExpectSteps.add(step);
155
201
  return;
156
202
  }
157
- // 2. Ignore custom expect wrapper steps ONLY if they are NOT custom matcher wrappers
158
- const isCustomWrapper = step.category === 'test.step' && step.parent && step.parent.category === 'expect' && customMatchers.includes(step.parent.title);
159
- if (step.category === 'test.step' && step.title.startsWith('expect(')) {
160
- if (!isCustomWrapper) {
161
- return;
162
- }
203
+ const isCustomWrapper = this.isSpecterWrapper(step);
204
+ // 2. Ignore other expect wrapper steps (e.g. from helpers that title steps "expect(...)")
205
+ if (step.category === 'test.step' && step.title.startsWith('expect(') && !isCustomWrapper) {
206
+ return;
163
207
  }
164
- // 3. Ignore inner expect steps nested under custom matchers
208
+ // 3. Ignore inner expect steps nested under matchers
165
209
  if (this.isNestedExpect(step) && !isCustomWrapper) {
166
210
  return;
167
211
  }
168
212
  const uniqueTestKey = `${test.parent.title} > ${test.title}`;
169
213
  let uniqueStepName = step.title;
170
214
  let category = step.category;
171
- // 4. Rewrite the title and category if this is the custom matcher wrapper step
215
+ // 4. Rename the wrapper to `Expect "<matcher>" @ <locator>` and report it as the expect step
172
216
  if (isCustomWrapper) {
173
- const parentTitle = step.parent ? step.parent.title : '';
174
- let assertionName = '';
175
- const match = parentTitle.match(/Expect "([^"]+)"/);
176
- if (match) {
177
- assertionName = match[1];
178
- }
179
- else {
180
- assertionName = parentTitle.replace(/^Expect\s+/, '');
181
- }
182
- let locator = '';
183
- if (step.title.includes('@')) {
184
- const parts = step.title.split('@');
185
- locator = parts[parts.length - 1].trim();
186
- }
187
- else if (step.title.startsWith('expect(')) {
188
- locator = extractLocatorFromExpectTitle(step.title);
189
- }
190
- const isNot = step.title.includes('.not.') || step.title.startsWith('not.');
191
- const prefix = isNot ? `not.${assertionName}` : assertionName;
192
- if (locator) {
193
- uniqueStepName = `Expect "${prefix}" @ ${locator}`;
194
- }
195
- else {
196
- uniqueStepName = `Expect "${prefix}"`;
197
- }
217
+ const parsed = (0, specter_matcher_report_1.parseSpecterExpectTitle)(step.parent.title);
218
+ const prefix = parsed.isNot ? `not.${parsed.matcher}` : parsed.matcher;
219
+ const locator = extractLocatorFromMatcherTitle(step.title);
220
+ uniqueStepName = locator ? `Expect "${prefix}" @ ${locator}` : `Expect "${prefix}"`;
198
221
  category = 'expect';
199
- // Cache the rewritten title on the parent step so we can retrieve it when the parent ends
222
+ // Cache the name on the outer expect step so its end event uses the same name
200
223
  this.stepIdMap.set(step.parent, uniqueStepName);
201
224
  }
202
225
  this.stepIdMap.set(step, uniqueStepName);
@@ -205,62 +228,75 @@ class SpecterReporter {
205
228
  payload: {
206
229
  testName: uniqueTestKey,
207
230
  stepName: uniqueStepName,
208
- parentStepName: this.getParentStepName(step),
231
+ // The wrapper stands in for its outer expect step, so report the expect step's parent
232
+ // (the same parent its step_ended event will carry), not the expect step itself.
233
+ parentStepName: this.getParentStepName(isCustomWrapper ? step.parent : step),
209
234
  category: category
210
235
  }
211
236
  });
212
237
  }
213
238
  customStepDurations = new WeakMap();
214
239
  onStepEnd(test, result, step) {
215
- const customMatchers = [
216
- 'Expect "toBeVisible"',
217
- 'Expect "toHavePropertyValue"',
218
- 'Expect "toHaveAttributeValue"',
219
- 'Expect "toHaveGameplayTag"',
220
- 'Expect "toHaveGameplayEffect"',
221
- 'Expect "toHaveMaterialScalarParameter"',
222
- 'Expect "toHaveMaterialVectorParameter"',
223
- 'Expect "toHaveMaterial"',
224
- 'Expect "toBeDynamicMaterial"',
225
- 'Expect "toHaveMaterialTextureParameter"'
226
- ];
227
- // 1. Handle outer Playwright-generated expect steps for custom matchers
228
- if (step.category === 'expect' && customMatchers.includes(step.title)) {
229
- const rewrittenName = this.stepIdMap.get(step);
230
- if (!rewrittenName) {
231
- return; // Ignore if not a custom matcher we tracked
232
- }
233
- }
234
- // 2. Ignore custom expect wrapper steps entirely (they are replaced by the outer step ending)
235
- const isCustomWrapper = step.category === 'test.step' && step.parent && step.parent.category === 'expect' && customMatchers.includes(step.parent.title);
236
- if (isCustomWrapper || (step.category === 'test.step' && step.title.startsWith('expect('))) {
240
+ const uniqueTestKey = `${test.parent.title} > ${test.title}`;
241
+ // 1. The wrapper's timing is reported by its outer expect step, which ends right after it
242
+ if (this.isSpecterWrapper(step) || (step.category === 'test.step' && step.title.startsWith('expect('))) {
237
243
  if (step.parent) {
238
244
  this.customStepDurations.set(step.parent, step.duration);
239
245
  }
240
246
  return;
241
247
  }
242
- // 3. Ignore inner expect steps nested under custom matchers
243
- if (this.isNestedExpect(step) && !isCustomWrapper) {
248
+ // 2. Ignore inner expect steps nested under matchers
249
+ if (this.isNestedExpect(step)) {
244
250
  return;
245
251
  }
246
- const uniqueTestKey = `${test.parent.title} > ${test.title}`;
247
- const uniqueStepName = this.stepIdMap.get(step) || step.title;
248
- const category = step.category;
252
+ const isSpecterExpect = this.specterExpectSteps.has(step);
253
+ let uniqueStepName = this.stepIdMap.get(step) || step.title;
254
+ // 3. A Specter expect step whose wrapper never started (the matcher failed before it could):
255
+ // announce it now so the runner still shows the failure.
256
+ if (isSpecterExpect && !this.stepIdMap.has(step)) {
257
+ uniqueStepName = step.title;
258
+ this.send({
259
+ event: 'step_started',
260
+ payload: {
261
+ testName: uniqueTestKey,
262
+ stepName: uniqueStepName,
263
+ parentStepName: this.getParentStepName(step),
264
+ category: 'expect'
265
+ }
266
+ });
267
+ }
249
268
  let duration = step.duration || 0;
250
269
  if (this.customStepDurations.has(step)) {
251
270
  duration = this.customStepDurations.get(step);
252
271
  }
272
+ const payload = {
273
+ testName: uniqueTestKey,
274
+ stepName: uniqueStepName,
275
+ parentStepName: this.getParentStepName(step),
276
+ category: isSpecterExpect ? 'expect' : step.category,
277
+ status: step.error ? 'failed' : 'passed',
278
+ duration: duration,
279
+ errorMessage: step.error ? this.formatError(step.error, result) : ''
280
+ };
281
+ // 4. Structured result for the runner's results grid (Specter matchers only)
282
+ const report = isSpecterExpect ? this.readMatcherReport(step) : undefined;
283
+ if (report) {
284
+ payload.matcherResult = {
285
+ matcher: report.matcher,
286
+ isNot: report.isNot,
287
+ pass: report.pass,
288
+ locator: report.locator,
289
+ locatorLabel: report.locatorLabel ?? '',
290
+ client: report.client ?? '',
291
+ expected: report.expected ?? null,
292
+ actual: report.actual ?? null,
293
+ expectedText: toDisplayText(report.expected),
294
+ actualText: toDisplayText(report.actual)
295
+ };
296
+ }
253
297
  this.send({
254
298
  event: 'step_ended',
255
- payload: {
256
- testName: uniqueTestKey,
257
- stepName: uniqueStepName,
258
- parentStepName: this.getParentStepName(step),
259
- category: category,
260
- status: step.error ? 'failed' : 'passed',
261
- duration: duration,
262
- errorMessage: step.error ? this.formatError(step.error, result) : ''
263
- }
299
+ payload
264
300
  });
265
301
  }
266
302
  formatError(error, result) {
package/dist/index.d.ts CHANGED
@@ -3,6 +3,9 @@ export { SpecterTransport, SpecterWorld, VectorUtils } from './core/specter-clie
3
3
  export type { SpecterPayload, SpawnOptions, Vector3, Rotator, LinearColor, Color, Vector2D, SpecterRegistry, SpecterFunctionRegistry, LoadMapOptions, SpecterGrantedAbility, SpecterActiveEffect, SpecterActorSnapshot, RegisteredGameplayTags } from './core/specter-client';
4
4
  export { SpecterLocator, WidgetLocator, ActorLocator, AiControllerLocator, type WidgetGeometry } from './core/locators';
5
5
  export { default as SpecterReporter } from './core/specter-reporter';
6
+ export { expectAll } from './core/expect-all';
7
+ export { SPECTER_MATCHER_ATTACHMENT } from './core/specter-matcher-report';
8
+ export type { SpecterMatcherReport } from './core/specter-matcher-report';
6
9
  export type { UnrealKey } from './core/specter-keys';
7
10
  export type { SpecterActorEvents, SpecterWidgetEvents, SpecterWorldEvents, CustomActorEvents, CustomWidgetEvents, CustomWorldEvents, ActorEventMap, WidgetEventMap, WorldEventMap, EventPredicate, WaitForEventOptions } from './core/events';
8
11
  export { SpecterInputSequence } from './core/specter-input-sequence';
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.aiExpect = exports.materialExpect = exports.runConditionalInputLoop = exports.evaluateCondition = exports.SpecterNetwork = exports.SpecterInputSequence = exports.SpecterReporter = exports.AiControllerLocator = exports.ActorLocator = exports.WidgetLocator = exports.SpecterLocator = exports.VectorUtils = exports.SpecterWorld = exports.SpecterTransport = exports.expect = exports.test = void 0;
6
+ exports.aiExpect = exports.materialExpect = exports.runConditionalInputLoop = exports.evaluateCondition = exports.SpecterNetwork = exports.SpecterInputSequence = exports.SPECTER_MATCHER_ATTACHMENT = exports.expectAll = exports.SpecterReporter = exports.AiControllerLocator = exports.ActorLocator = exports.WidgetLocator = exports.SpecterLocator = exports.VectorUtils = exports.SpecterWorld = exports.SpecterTransport = exports.expect = exports.test = void 0;
7
7
  var test_wrapper_1 = require("./core/test-wrapper");
8
8
  Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_wrapper_1.test; } });
9
9
  Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_wrapper_1.expect; } });
@@ -18,6 +18,10 @@ Object.defineProperty(exports, "ActorLocator", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "AiControllerLocator", { enumerable: true, get: function () { return locators_1.AiControllerLocator; } });
19
19
  var specter_reporter_1 = require("./core/specter-reporter");
20
20
  Object.defineProperty(exports, "SpecterReporter", { enumerable: true, get: function () { return __importDefault(specter_reporter_1).default; } });
21
+ var expect_all_1 = require("./core/expect-all");
22
+ Object.defineProperty(exports, "expectAll", { enumerable: true, get: function () { return expect_all_1.expectAll; } });
23
+ var specter_matcher_report_1 = require("./core/specter-matcher-report");
24
+ Object.defineProperty(exports, "SPECTER_MATCHER_ATTACHMENT", { enumerable: true, get: function () { return specter_matcher_report_1.SPECTER_MATCHER_ATTACHMENT; } });
21
25
  var specter_input_sequence_1 = require("./core/specter-input-sequence");
22
26
  Object.defineProperty(exports, "SpecterInputSequence", { enumerable: true, get: function () { return specter_input_sequence_1.SpecterInputSequence; } });
23
27
  var specter_network_1 = require("./core/specter-network");