@specter-automation/test 1.0.159 → 1.0.160
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.
|
@@ -129,6 +129,11 @@ export interface SpecterDiagnosticsReport {
|
|
|
129
129
|
worldTime: number;
|
|
130
130
|
deltaSeconds: number;
|
|
131
131
|
};
|
|
132
|
+
/** What the test before this one left changed: a moved pawn or camera, a screen left open, pause */
|
|
133
|
+
previousTestLeftChanged?: {
|
|
134
|
+
test: string;
|
|
135
|
+
changes: string[];
|
|
136
|
+
};
|
|
132
137
|
}
|
|
133
138
|
export type { Vector3, Vector2D, Rotator, Transform } from './specter-math';
|
|
134
139
|
export { VectorUtils, RotatorUtils, resolveVector3, resolveRotator, normalizeAxis, findLookAtRotation, getRotationBetween, calculateDistance, calculateDistance2D, normalizeRotator, deltaRotator } from './specter-math';
|
|
@@ -570,6 +575,17 @@ export declare class SpecterWorld {
|
|
|
570
575
|
map: string;
|
|
571
576
|
serverAddress: string;
|
|
572
577
|
}>;
|
|
578
|
+
/**
|
|
579
|
+
* Notes the state a test can leave behind for the next one (each player's pawn and camera, the screens
|
|
580
|
+
* showing, pause, time dilation). The test fixture calls it when a test starts; `endLeftStateCheck` compares.
|
|
581
|
+
* Does nothing on a plugin that doesn't have it.
|
|
582
|
+
*/
|
|
583
|
+
beginLeftStateCheck(testName: string): Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* What changed since `beginLeftStateCheck`, after the test's afterEach hooks. Specter can't put the game
|
|
586
|
+
* back itself (only the game knows its starting state), but the next test's failure report names these.
|
|
587
|
+
*/
|
|
588
|
+
endLeftStateCheck(): Promise<string[]>;
|
|
573
589
|
cleanup(): Promise<void>;
|
|
574
590
|
/**
|
|
575
591
|
* Restores the primary PlayerController to its pre-possession state
|
|
@@ -1209,6 +1209,32 @@ class SpecterWorld {
|
|
|
1209
1209
|
const response = await this.evaluate("GetNetworkStatus", {});
|
|
1210
1210
|
return response.data;
|
|
1211
1211
|
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Notes the state a test can leave behind for the next one (each player's pawn and camera, the screens
|
|
1214
|
+
* showing, pause, time dilation). The test fixture calls it when a test starts; `endLeftStateCheck` compares.
|
|
1215
|
+
* Does nothing on a plugin that doesn't have it.
|
|
1216
|
+
*/
|
|
1217
|
+
async beginLeftStateCheck(testName) {
|
|
1218
|
+
try {
|
|
1219
|
+
await this.evaluate("BeginLeftStateCheck", { testName }, undefined, undefined, true);
|
|
1220
|
+
}
|
|
1221
|
+
catch (e) {
|
|
1222
|
+
// An older plugin: no check
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* What changed since `beginLeftStateCheck`, after the test's afterEach hooks. Specter can't put the game
|
|
1227
|
+
* back itself (only the game knows its starting state), but the next test's failure report names these.
|
|
1228
|
+
*/
|
|
1229
|
+
async endLeftStateCheck() {
|
|
1230
|
+
try {
|
|
1231
|
+
const response = await this.evaluate("EndLeftStateCheck", {}, undefined, undefined, true);
|
|
1232
|
+
return Array.isArray(response?.data?.changes) ? response.data.changes : [];
|
|
1233
|
+
}
|
|
1234
|
+
catch (e) {
|
|
1235
|
+
return [];
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1212
1238
|
async cleanup() {
|
|
1213
1239
|
if (!this.transport.isConnected)
|
|
1214
1240
|
return;
|
|
@@ -79,11 +79,20 @@ const extendedTest = test_1.test.extend({
|
|
|
79
79
|
if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
|
|
80
80
|
await world.console(`r.FixedDeltaTime ${fixedDeltaSeconds}`);
|
|
81
81
|
}
|
|
82
|
+
// Tests share one game: note what this one might leave changed for the next
|
|
83
|
+
await world.beginLeftStateCheck(testInfo.titlePath.slice(1).join(' > '));
|
|
82
84
|
try {
|
|
83
85
|
await use(world);
|
|
84
86
|
}
|
|
85
87
|
finally {
|
|
86
88
|
(0, failure_capture_1.setActiveWorld)(null);
|
|
89
|
+
// After afterEach: what this test left changed. Said here, on the test that did it, and again in the
|
|
90
|
+
// next test's failure report.
|
|
91
|
+
const leftChanged = await world.endLeftStateCheck();
|
|
92
|
+
if (leftChanged.length > 0) {
|
|
93
|
+
console.warn(`[SPECTER] This test left the game changed for the next test:\n${leftChanged.map(change => ` - ${change}`).join('\n')}\n` +
|
|
94
|
+
` Specter can't reset game state (only the game knows its start). Reset it in your fixture or afterEach if later tests depend on it.`);
|
|
95
|
+
}
|
|
87
96
|
// Teardown: Reset fixed delta time if configured
|
|
88
97
|
if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
|
|
89
98
|
try {
|
|
@@ -69,6 +69,16 @@ function formatAiDiagnostics(diagnostics) {
|
|
|
69
69
|
lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
70
70
|
lines.push('🧠 SPECTER AI DIAGNOSTICS REPORT');
|
|
71
71
|
lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
72
|
+
// 0. What the test before this one left changed. First: in a full run it's often the whole story.
|
|
73
|
+
const left = diagnostics.previousTestLeftChanged;
|
|
74
|
+
if (left?.changes?.length) {
|
|
75
|
+
lines.push(`⚠️ The previous test${left.test ? ` ("${left.test}")` : ''} left the game changed:`);
|
|
76
|
+
for (const change of left.changes) {
|
|
77
|
+
lines.push(` • ${change}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push(' If this test expects the starting state, reset it in the project\'s fixture or a beforeEach/afterEach.');
|
|
80
|
+
lines.push('');
|
|
81
|
+
}
|
|
72
82
|
// 1. Actor Identity Mapping
|
|
73
83
|
if (diagnostics.actorMap && Object.keys(diagnostics.actorMap).length > 0) {
|
|
74
84
|
lines.push('📍 Actor Identity Mapping:');
|