@fliwright/vitest 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +14 -2
- package/dist/AttemptContext.d.ts +73 -0
- package/dist/AttemptContext.js +296 -0
- package/dist/FinalizationBudget.d.ts +15 -0
- package/dist/FinalizationBudget.js +57 -0
- package/dist/RecoveryReporter.d.ts +6 -0
- package/dist/RecoveryReporter.js +15 -0
- package/dist/TaskEndpointLease.d.ts +8 -0
- package/dist/TaskEndpointLease.js +28 -0
- package/dist/TestRegistration.d.ts +8 -0
- package/dist/TestRegistration.js +52 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.js +658 -0
- package/dist/preset.d.ts +17 -0
- package/dist/preset.js +28 -0
- package/dist/reporter.d.ts +5 -0
- package/dist/reporter.js +20 -0
- package/dist/runner.d.ts +24 -0
- package/dist/runner.js +322 -0
- package/dist/setup.d.ts +7 -0
- package/dist/setup.js +15 -0
- package/package.json +58 -3
package/dist/preset.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { mergeFliwrightConfig, readFliwrightEnvironment, resolveFliwrightProjectRoot, resolveFliwrightRunsRoot, resolveFliwrightCacheRoot } from '@fliwright/core';
|
|
3
|
+
/** Returns a Vitest config fragment using the built Fliwright runner adapter. */
|
|
4
|
+
export function fliwrightPreset(options = {}) {
|
|
5
|
+
const config = mergeFliwrightConfig({ project: options, environment: readFliwrightEnvironment(process.env) });
|
|
6
|
+
const projectRoot = options.projectRoot ?? process.env.FLIWRIGHT_PROJECT_ROOT ?? resolveFliwrightProjectRoot();
|
|
7
|
+
config.runsRoot = resolveFliwrightRunsRoot({ projectRoot, runsRoot: config.runsRoot, env: {} });
|
|
8
|
+
config.cacheRoot = resolveFliwrightCacheRoot({ projectRoot, cacheRoot: config.cacheRoot });
|
|
9
|
+
const reporters = options.test?.reporters ?? ['default'];
|
|
10
|
+
const env = {
|
|
11
|
+
FLIWRIGHT_PROJECT_ROOT: projectRoot,
|
|
12
|
+
FLIWRIGHT_CONFIG: JSON.stringify(config),
|
|
13
|
+
FLIWRIGHT_RECORDING_MODE: config.recording.mode,
|
|
14
|
+
...(config.runsRoot ? { FLIWRIGHT_RUNS_ROOT: config.runsRoot } : {}),
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
test: {
|
|
18
|
+
runner: options.runner ?? fileURLToPath(new URL('./runner.js', import.meta.url)),
|
|
19
|
+
include: [`${config.paths.tests}/**/*.test.ts`, `${config.paths.scripts}/**/*.script.ts`],
|
|
20
|
+
...options.test,
|
|
21
|
+
reporters: [
|
|
22
|
+
...(Array.isArray(reporters) ? reporters : [reporters]),
|
|
23
|
+
fileURLToPath(new URL('./RecoveryReporter.js', import.meta.url)),
|
|
24
|
+
],
|
|
25
|
+
env: { ...options.test?.env, ...env },
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
package/dist/reporter.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class FliwrightReporter {
|
|
2
|
+
onInit() { }
|
|
3
|
+
onFinished(files) {
|
|
4
|
+
for (const file of files) {
|
|
5
|
+
for (const task of file.tasks) {
|
|
6
|
+
if (task.type === 'test' && task.result?.state === 'fail') {
|
|
7
|
+
const errors = task.result.errors ?? [];
|
|
8
|
+
for (const err of errors) {
|
|
9
|
+
if (err.stack) {
|
|
10
|
+
const failureMatch = err.stack.match(/\.fliwright\/failures\/[^\s]+\.png/);
|
|
11
|
+
if (failureMatch) {
|
|
12
|
+
console.log(` Screenshot: ${failureMatch[0]}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TestRunner as VitestTestRunner } from 'vitest';
|
|
2
|
+
import type { RunnerTask as Task } from 'vitest';
|
|
3
|
+
import { RunSession } from '@fliwright/core';
|
|
4
|
+
import type { RunSessionResult } from '@fliwright/core';
|
|
5
|
+
export interface FliwrightRunnerOptions {
|
|
6
|
+
createSession?: (task: Task, attemptIndex?: number) => RunSession;
|
|
7
|
+
onSessionStart?: (session: RunSession, task: Task, attemptIndex?: number) => void | Promise<void>;
|
|
8
|
+
/** Called after setup/body and again after teardown, before finalization. */
|
|
9
|
+
onAttemptFinished?: (task: Task, retry: number, session: RunSession) => void | Promise<void>;
|
|
10
|
+
/** Called once with the final runner outcome for a task. */
|
|
11
|
+
onSessionFinished?: (task: Task, result: RunSessionResult) => void | Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface FliwrightRunnerConstructor {
|
|
14
|
+
new (config: ConstructorParameters<typeof VitestTestRunner>[0], options?: FliwrightRunnerOptions): VitestTestRunner;
|
|
15
|
+
}
|
|
16
|
+
/** Compose the lifecycle with an existing VitestTestRunner subclass, retaining its constructor and hooks.
|
|
17
|
+
* The base runner must call its own Vitest super hooks to preserve assertion/snapshot semantics.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createFliwrightRunner(BaseRunner: typeof VitestTestRunner): FliwrightRunnerConstructor;
|
|
20
|
+
declare const FliwrightRunner_base: FliwrightRunnerConstructor;
|
|
21
|
+
/** Default lifecycle adapter using Vitest's standard runner. */
|
|
22
|
+
export declare class FliwrightRunner extends FliwrightRunner_base {
|
|
23
|
+
}
|
|
24
|
+
export default FliwrightRunner;
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { TestRunner as VitestTestRunner } from 'vitest';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { appendFile } from 'node:fs/promises';
|
|
4
|
+
import { relative } from 'node:path';
|
|
5
|
+
import { RunSession, registerRunSession, unregisterRunSession } from '@fliwright/core';
|
|
6
|
+
import { AttemptContext, setAttemptContext } from './AttemptContext.js';
|
|
7
|
+
import { releaseTaskEndpointLease, finishTaskEndpointLeasePhase } from './TaskEndpointLease.js';
|
|
8
|
+
import { prepareRegisteredTask } from './TestRegistration.js';
|
|
9
|
+
/** Compose the lifecycle with an existing VitestTestRunner subclass, retaining its constructor and hooks.
|
|
10
|
+
* The base runner must call its own Vitest super hooks to preserve assertion/snapshot semantics.
|
|
11
|
+
*/
|
|
12
|
+
export function createFliwrightRunner(BaseRunner) {
|
|
13
|
+
class ComposedFliwrightRunner extends BaseRunner {
|
|
14
|
+
options;
|
|
15
|
+
runId = process.env.FLIWRIGHT_RUN_ID ?? `run-${randomUUID()}`;
|
|
16
|
+
active = new Map();
|
|
17
|
+
completed = new Map();
|
|
18
|
+
tasks = new Set();
|
|
19
|
+
preparationController = new AbortController();
|
|
20
|
+
constructor(config, options = {}) {
|
|
21
|
+
super(config);
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
async onBeforeRunFiles(files) {
|
|
25
|
+
this.preparationController = new AbortController();
|
|
26
|
+
await callBase('onBeforeRunFiles', this, files);
|
|
27
|
+
this.runId = process.env.FLIWRIGHT_RUN_ID ?? `run-${randomUUID()}`;
|
|
28
|
+
}
|
|
29
|
+
cancel(reason) {
|
|
30
|
+
try {
|
|
31
|
+
return BaseRunner.prototype.cancel.call(this, reason);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
this.preparationController.abort(new Error(`Test run canceled while preparing the App: ${reason}`));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async onAfterRunFiles(files) {
|
|
38
|
+
try {
|
|
39
|
+
await callBase('onAfterRunFiles', this, files);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
for (const task of this.tasks)
|
|
43
|
+
await releaseTaskEndpointLease(task);
|
|
44
|
+
this.tasks.clear();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async onBeforeRunTask(task) {
|
|
48
|
+
this.tasks.add(task);
|
|
49
|
+
const configuredRunId = process.env.FLIWRIGHT_RUN_ID;
|
|
50
|
+
if (configuredRunId && configuredRunId !== this.runId)
|
|
51
|
+
this.runId = configuredRunId;
|
|
52
|
+
else if (process.env.FLIWRIGHT_TDD_MODE === '1')
|
|
53
|
+
this.runId = `run-${randomUUID()}`;
|
|
54
|
+
await callBase('onBeforeRunTask', this, task);
|
|
55
|
+
await this.startAttempt(task, 0);
|
|
56
|
+
if (task.mode === 'run' || task.mode === 'queued') {
|
|
57
|
+
try {
|
|
58
|
+
await prepareRegisteredTask(task, this.preparationController.signal);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const canceled = this.preparationController.signal.aborted;
|
|
62
|
+
// Vitest does not register a running task until this hook returns,
|
|
63
|
+
// so its cancellation wrapper cannot abort this preparation wait.
|
|
64
|
+
const context = this.active.get(task.id)?.context;
|
|
65
|
+
const message = context?.session.redactReport(error instanceof Error ? error.message : String(error))
|
|
66
|
+
?? 'App preparation failed.';
|
|
67
|
+
const outcome = canceled ? 'interrupted' : 'failed';
|
|
68
|
+
try {
|
|
69
|
+
if (canceled) {
|
|
70
|
+
task.mode = 'skip';
|
|
71
|
+
context?.runnerErrors.push({ message, phase: 'setup-or-body' });
|
|
72
|
+
context?.recordEvidenceIssue(error);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Returning a failed task uses Vitest's early-failure path;
|
|
76
|
+
// throwing here would abort the enclosing file and its peers.
|
|
77
|
+
task.result = { state: 'fail', errors: [{
|
|
78
|
+
name: error instanceof Error ? error.name : 'Error', message,
|
|
79
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
80
|
+
}] };
|
|
81
|
+
await context?.captureRunnerFailures(task, 'setup-or-body');
|
|
82
|
+
}
|
|
83
|
+
await this.finishAttempt(task, outcome);
|
|
84
|
+
await this.finalizeTask(task, outcome);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
await releaseTaskEndpointLease(task);
|
|
88
|
+
this.tasks.delete(task);
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Pre-skipped tasks do not reach any later runner hook.
|
|
94
|
+
if (task.mode !== 'run' && task.mode !== 'queued') {
|
|
95
|
+
await this.finishAttempt(task, 'skipped');
|
|
96
|
+
await this.finalizeTask(task, 'skipped');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async onBeforeTryTask(task, options = {}) {
|
|
100
|
+
const configuredRunId = process.env.FLIWRIGHT_RUN_ID;
|
|
101
|
+
if (configuredRunId && configuredRunId !== this.runId)
|
|
102
|
+
this.runId = configuredRunId;
|
|
103
|
+
else if (process.env.FLIWRIGHT_TDD_MODE === '1' && !this.active.has(task.id) && !this.completed.has(task.id)) {
|
|
104
|
+
this.runId = `run-${randomUUID()}`;
|
|
105
|
+
}
|
|
106
|
+
await callBase('onBeforeTryTask', this, task, options);
|
|
107
|
+
let record = this.active.get(task.id);
|
|
108
|
+
if (record?.started) {
|
|
109
|
+
// Includes aroundEach teardown, which runs after onAfterRetryTask.
|
|
110
|
+
await record.context.captureRunnerFailures(task, 'teardown');
|
|
111
|
+
await this.finishAttempt(task, record.observedStatus ?? 'failed');
|
|
112
|
+
record = undefined;
|
|
113
|
+
}
|
|
114
|
+
record ??= await this.startAttempt(task, this.completed.get(task.id)?.length ?? 0);
|
|
115
|
+
record.started = true;
|
|
116
|
+
record.context.runnerEntered = true;
|
|
117
|
+
}
|
|
118
|
+
async onTaskFinished(task) {
|
|
119
|
+
await callBase('onTaskFinished', this, task);
|
|
120
|
+
const record = this.active.get(task.id);
|
|
121
|
+
if (!record)
|
|
122
|
+
return;
|
|
123
|
+
record.context.finalization.begin();
|
|
124
|
+
if (task.result?.state === 'pass') {
|
|
125
|
+
const validationError = record.context.validate?.();
|
|
126
|
+
if (validationError) {
|
|
127
|
+
task.result.state = 'fail';
|
|
128
|
+
(task.result.errors ??= []).push({ name: validationError.name, message: validationError.message, stack: validationError.stack });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
await record.context.captureRunnerFailures(task, 'setup-or-body');
|
|
132
|
+
if (this.options.onAttemptFinished)
|
|
133
|
+
await record.context.finalizeStep('Attempt callback', async () => {
|
|
134
|
+
await this.options.onAttemptFinished(task, record.attemptIndex, record.session);
|
|
135
|
+
});
|
|
136
|
+
record.context.finalization.pause();
|
|
137
|
+
}
|
|
138
|
+
async onAfterRetryTask(task, options) {
|
|
139
|
+
await callBase('onAfterRetryTask', this, task, options);
|
|
140
|
+
const record = this.active.get(task.id);
|
|
141
|
+
if (!record)
|
|
142
|
+
return;
|
|
143
|
+
await record.context.captureRunnerFailures(task, 'teardown');
|
|
144
|
+
if (this.options.onAttemptFinished)
|
|
145
|
+
await record.context.finalizeStep('Attempt callback', async () => {
|
|
146
|
+
await this.options.onAttemptFinished(task, record.attemptIndex, record.session);
|
|
147
|
+
});
|
|
148
|
+
record.observedStatus = outcomeForTask(task);
|
|
149
|
+
record.context.runnerEntered = false;
|
|
150
|
+
// Runtime skip returns before onAfterRunTask too.
|
|
151
|
+
if (record.observedStatus === 'skipped') {
|
|
152
|
+
try {
|
|
153
|
+
await this.finishAttempt(task, 'skipped');
|
|
154
|
+
await this.finalizeTask(task, 'skipped');
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
await finishTaskEndpointLeasePhase(task, 'skipFinalized');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async onAfterRunTask(task) {
|
|
162
|
+
try {
|
|
163
|
+
await callBase('onAfterRunTask', this, task);
|
|
164
|
+
const record = this.active.get(task.id);
|
|
165
|
+
if (record) {
|
|
166
|
+
await record.context.captureRunnerFailures(task, 'final');
|
|
167
|
+
const finalStatus = outcomeForTask(task);
|
|
168
|
+
const observedStatus = isExpectedFailure(task)
|
|
169
|
+
? finalStatus === 'passed' ? 'failed' : 'passed'
|
|
170
|
+
: finalStatus;
|
|
171
|
+
await this.finishAttempt(task, observedStatus);
|
|
172
|
+
}
|
|
173
|
+
await this.finalizeTask(task, outcomeForTask(task));
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
await releaseTaskEndpointLease(task);
|
|
177
|
+
this.tasks.delete(task);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async startAttempt(task, attemptIndex) {
|
|
181
|
+
const runId = this.runId;
|
|
182
|
+
const attemptId = `attempt-${attemptIndex}`;
|
|
183
|
+
const session = this.options.createSession?.(task, attemptIndex) ?? new RunSession({
|
|
184
|
+
runId, testId: task.id, testName: task.name, attemptId, attemptIndex,
|
|
185
|
+
testFile: relative(this.config.root, task.file.filepath).split('\\').join('/'),
|
|
186
|
+
testPath: sourceTestPath(task),
|
|
187
|
+
});
|
|
188
|
+
const context = new AttemptContext(session, runId, task.id, task.name, attemptId);
|
|
189
|
+
if (attemptIndex > 0)
|
|
190
|
+
context.ignorePriorFailures(task);
|
|
191
|
+
const record = { session, context, attemptIndex, started: false };
|
|
192
|
+
context.beforeFixtures = async () => {
|
|
193
|
+
const previous = this.active.get(task.id);
|
|
194
|
+
if (!previous?.started || previous.context.runnerEntered)
|
|
195
|
+
return;
|
|
196
|
+
// aroundEach resolves automatic fixtures before onBeforeTryTask.
|
|
197
|
+
// Finish the preceding attempt before any new scenario preparation.
|
|
198
|
+
await previous.context.captureRunnerFailures(task, 'teardown');
|
|
199
|
+
await this.finishAttempt(task, previous.observedStatus ?? 'failed');
|
|
200
|
+
await this.startAttempt(task, this.completed.get(task.id)?.length ?? 0);
|
|
201
|
+
};
|
|
202
|
+
context.onSetupSkipped = async () => {
|
|
203
|
+
const active = this.active.get(task.id);
|
|
204
|
+
if (!active)
|
|
205
|
+
return;
|
|
206
|
+
// A retry may skip in aroundEach before onBeforeTryTask can finish
|
|
207
|
+
// the previous attempt and create the new one.
|
|
208
|
+
if (active.started) {
|
|
209
|
+
await this.finishAttempt(task, active.observedStatus ?? 'failed');
|
|
210
|
+
await this.startAttempt(task, this.completed.get(task.id)?.length ?? 0);
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
await this.finishAttempt(task, 'skipped');
|
|
214
|
+
await this.finalizeTask(task, 'skipped');
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
await finishTaskEndpointLeasePhase(task, 'skipFinalized');
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
this.active.set(task.id, record);
|
|
221
|
+
registerRunSession(task.id, session);
|
|
222
|
+
setAttemptContext(task, context);
|
|
223
|
+
await context.initialize();
|
|
224
|
+
await this.options.onSessionStart?.(session, task, attemptIndex);
|
|
225
|
+
return record;
|
|
226
|
+
}
|
|
227
|
+
async finishAttempt(task, status) {
|
|
228
|
+
const record = this.active.get(task.id);
|
|
229
|
+
if (!record)
|
|
230
|
+
return;
|
|
231
|
+
if (record.context.beforeFinish) {
|
|
232
|
+
await record.context.finalizeStep('Passive diagnosis', (signal) => record.context.beforeFinish(signal));
|
|
233
|
+
}
|
|
234
|
+
const result = await record.session.finish({ status, evidenceStatus: 'complete' });
|
|
235
|
+
result.expectedFailure = isExpectedFailure(task);
|
|
236
|
+
if (record.context.evidenceErrors.length && result.evidenceStatus !== 'disabled')
|
|
237
|
+
result.evidenceStatus = 'partial';
|
|
238
|
+
result.failureContextPath = record.context.failureContextPath;
|
|
239
|
+
result.runnerErrors = [...record.context.runnerErrors];
|
|
240
|
+
this.active.delete(task.id);
|
|
241
|
+
unregisterRunSession(task.id, record.session);
|
|
242
|
+
const attempts = this.completed.get(task.id) ?? [];
|
|
243
|
+
attempts.push({ context: record.context, result });
|
|
244
|
+
this.completed.set(task.id, attempts);
|
|
245
|
+
await record.context.persist(result);
|
|
246
|
+
}
|
|
247
|
+
async finalizeTask(task, testOutcome) {
|
|
248
|
+
const attempts = this.completed.get(task.id) ?? [];
|
|
249
|
+
const flaky = testOutcome === 'passed' && !isExpectedFailure(task) && attempts.length > 1
|
|
250
|
+
&& attempts.some(({ result }) => result.attemptOutcome === 'failed');
|
|
251
|
+
// Earlier attempts may have finished before a long retry body. Refresh
|
|
252
|
+
// their task-level projections using the final attempt's remaining time.
|
|
253
|
+
const finalization = attempts.at(-1)?.context.finalization;
|
|
254
|
+
for (const { result } of attempts) {
|
|
255
|
+
result.testOutcome = testOutcome;
|
|
256
|
+
result.flaky = flaky;
|
|
257
|
+
}
|
|
258
|
+
const finalAttempt = attempts.at(-1);
|
|
259
|
+
if (finalAttempt && this.options.onSessionFinished) {
|
|
260
|
+
await finalAttempt.context.finalizeStep('Session callback', async () => {
|
|
261
|
+
await this.options.onSessionFinished(task, finalAttempt.result);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
for (const { context, result } of attempts) {
|
|
265
|
+
await context.persist(result, true, finalization);
|
|
266
|
+
const outputPath = process.env.FLIWRIGHT_SESSION_RESULTS_PATH;
|
|
267
|
+
if (outputPath && finalization)
|
|
268
|
+
try {
|
|
269
|
+
await finalization.run('Result handoff', () => appendFile(outputPath, `${JSON.stringify(result)}\n`, 'utf8'));
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
context.recordEvidenceIssue(error);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const result = attempts.at(-1)?.result;
|
|
276
|
+
if (result) {
|
|
277
|
+
task.fliwrightSessionResult = result;
|
|
278
|
+
task.meta.fliwrightRun = { runId: result.runId, testId: result.testId, attemptId: result.attemptId };
|
|
279
|
+
}
|
|
280
|
+
// Task metadata travels through Vitest's reporter channel even when the
|
|
281
|
+
// worker cannot flush its artifact store. Only affected attempts pay for
|
|
282
|
+
// this snapshot; regular runs keep the compact identity above.
|
|
283
|
+
const recovery = attempts.filter(({ context }) => context.persistenceIncomplete).map(({ context, result }) => ({
|
|
284
|
+
runsRoot: context.runsRoot,
|
|
285
|
+
result: context.session.redactReport(result),
|
|
286
|
+
...(context.recordingMode !== 'off' ? { timeline: context.session.redactReport(context.recorder.complete(result.testOutcome)) } : {}),
|
|
287
|
+
}));
|
|
288
|
+
if (recovery.length)
|
|
289
|
+
task.meta.fliwrightRecovery = recovery;
|
|
290
|
+
this.completed.delete(task.id);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
async function callBase(name, runner, ...args) {
|
|
294
|
+
const method = BaseRunner.prototype[name];
|
|
295
|
+
if (typeof method === 'function')
|
|
296
|
+
await method.call(runner, ...args);
|
|
297
|
+
}
|
|
298
|
+
return ComposedFliwrightRunner;
|
|
299
|
+
}
|
|
300
|
+
/** Default lifecycle adapter using Vitest's standard runner. */
|
|
301
|
+
export class FliwrightRunner extends createFliwrightRunner(VitestTestRunner) {
|
|
302
|
+
}
|
|
303
|
+
function sourceTestPath(task) {
|
|
304
|
+
const names = [task.name];
|
|
305
|
+
let suite = task.suite;
|
|
306
|
+
while (suite && suite !== task.file) {
|
|
307
|
+
names.unshift(suite.name);
|
|
308
|
+
suite = suite.suite;
|
|
309
|
+
}
|
|
310
|
+
return names;
|
|
311
|
+
}
|
|
312
|
+
function isExpectedFailure(task) {
|
|
313
|
+
return task.type === 'test' && task.fails === true;
|
|
314
|
+
}
|
|
315
|
+
function outcomeForTask(task) {
|
|
316
|
+
if (task.result?.state === 'pass')
|
|
317
|
+
return 'passed';
|
|
318
|
+
if (task.result?.state === 'skip')
|
|
319
|
+
return 'skipped';
|
|
320
|
+
return 'failed';
|
|
321
|
+
}
|
|
322
|
+
export default FliwrightRunner;
|
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FliwrightDriver } from '@fliwright/core';
|
|
2
|
+
export interface SetupOptions {
|
|
3
|
+
vmServiceUrl: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function globalSetup(options: SetupOptions): Promise<void>;
|
|
6
|
+
export declare function getDriver(): FliwrightDriver | null;
|
|
7
|
+
export declare function globalTeardown(): Promise<void>;
|
package/dist/setup.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FliwrightDriver } from '@fliwright/core';
|
|
2
|
+
let driver = null;
|
|
3
|
+
export async function globalSetup(options) {
|
|
4
|
+
driver = new FliwrightDriver();
|
|
5
|
+
await driver.connect(options.vmServiceUrl);
|
|
6
|
+
}
|
|
7
|
+
export function getDriver() {
|
|
8
|
+
return driver;
|
|
9
|
+
}
|
|
10
|
+
export async function globalTeardown() {
|
|
11
|
+
if (driver) {
|
|
12
|
+
await driver.dispose();
|
|
13
|
+
driver = null;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fliwright/vitest",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vitest fixtures and lifecycle integration for Fliwright Flutter E2E tests.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/0x01lab/fliwright.git",
|
|
9
|
+
"directory": "packages/fliwright-vitest"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/0x01lab/fliwright/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/0x01lab/fliwright#readme",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./preset": {
|
|
24
|
+
"types": "./dist/preset.d.ts",
|
|
25
|
+
"import": "./dist/preset.js"
|
|
26
|
+
},
|
|
27
|
+
"./runner": {
|
|
28
|
+
"types": "./dist/runner.d.ts",
|
|
29
|
+
"import": "./dist/runner.js"
|
|
30
|
+
},
|
|
31
|
+
"./reporter": {
|
|
32
|
+
"types": "./dist/RecoveryReporter.d.ts",
|
|
33
|
+
"import": "./dist/RecoveryReporter.js",
|
|
34
|
+
"default": "./dist/RecoveryReporter.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": "^22.12.0 || ^24.0.0 || >=26.0.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"vitest": "5.0.5",
|
|
50
|
+
"@fliwright/core": "0.1.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^25.9.1",
|
|
54
|
+
"typescript": "^5.5.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"lint": "tsc --noEmit"
|
|
60
|
+
}
|
|
6
61
|
}
|