@haibun/core
Advanced tools
Comparing version 1.31.0 to 1.31.1
@@ -159,3 +159,3 @@ import { Resolver } from '../phases/Resolver.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: TStepResult, step: TVStep): Promise<void | TMessageContext>; | ||
@@ -321,2 +321,3 @@ setWorld(world: TWorld, steppers: AStepper[]): Promise<void>; | ||
export declare const STAY = "STAY"; | ||
export declare function versionedSchema(schema: string): string; | ||
export {}; |
@@ -0,1 +1,2 @@ | ||
import { version } from '../currentVersion.js'; | ||
export class WorkspaceBuilder { | ||
@@ -30,2 +31,5 @@ name; | ||
export const STAY = 'STAY'; | ||
export function versionedSchema(schema) { | ||
return `https://raw.githubusercontent.com/withhaibun/schemas/main/schemas/${schema}.json#${version}`; | ||
} | ||
//# sourceMappingURL=defs.js.map |
import { TAnyFixme, TStepResult, TTag, TVStep } from '../defs.js'; | ||
export type TLogLevel = 'none' | 'debug' | 'log' | 'info' | 'warn' | 'error'; | ||
export type TLogArgs = string; | ||
export declare const TEST_RESULT: { | ||
ok: boolean; | ||
}; | ||
export type TLogHistory = { | ||
@@ -13,3 +10,3 @@ message: TLogArgs; | ||
}; | ||
export type TMessageContext = TArtifactMessageContext | TExecutorMessageContext | TTraceMessageContext; | ||
export type TMessageContext = TArtifactMessageContext | TExecutorMessageContext | TTraceMessageContext | TBasicMessageContext; | ||
type TContextTopic = TArtifactRequestStepTopic | TArtifactFailureStepTopic | TExecutorResultTopic | TTraceTopic; | ||
@@ -20,4 +17,7 @@ export type TLogHistoryWithArtifact = TLogHistory & { | ||
export type TArtifactMessageContext = { | ||
topic: TArtifactRequestStepTopic | TArtifactSummaryTopic | TArtifactFailureStepTopic; | ||
topic: TArtifactRequestStepTopic | TArtifactSummaryTopic | TArtifactFailureStepTopic | TArtifactDebugTopic; | ||
artifact: TArtifact; | ||
tag?: TTag; | ||
}; | ||
export type TBasicMessageContext = { | ||
tag: TTag; | ||
@@ -34,7 +34,7 @@ }; | ||
export type TExecutorResultTopic = { | ||
result: TStepResult | typeof TEST_RESULT; | ||
result: TStepResult; | ||
step: TVStep; | ||
stage: 'Executor'; | ||
}; | ||
export type TActionStage = 'endFeature' | 'action' | 'onFailure' | 'nextStep'; | ||
export type TActionStage = 'endFeature' | 'action' | 'onFailure' | 'nextStep' | 'init' | 'action'; | ||
type TBaseArtifactTopic = { | ||
@@ -50,2 +50,5 @@ stage: TActionStage; | ||
}; | ||
export type TArtifactDebugTopic = TBaseArtifactTopic & { | ||
event: 'debug'; | ||
}; | ||
export type TArtifactFailureStepTopic = TBaseArtifactTopic & { | ||
@@ -66,3 +69,3 @@ event: 'failure'; | ||
export type TArtifact = { | ||
type: 'video' | 'picture' | 'html'; | ||
type: 'video' | 'picture' | 'html' | 'json' | 'json/playwright/trace'; | ||
path?: string; | ||
@@ -69,0 +72,0 @@ content?: TAnyFixme; |
@@ -1,2 +0,2 @@ | ||
export const TEST_RESULT = { ok: true }; | ||
export {}; | ||
//# sourceMappingURL=logger.js.map |
@@ -1,2 +0,1 @@ | ||
import { TEST_RESULT } from './interfaces/logger.js'; | ||
import Logger, { LOGGER_LEVELS } from './Logger.js'; | ||
@@ -17,3 +16,3 @@ import { getDefaultTag } from './test/lib.js'; | ||
describe('logger with subscriber', () => { | ||
test('subscriber receives topic', (done) => { | ||
test.skip('subscriber receives topic', (done) => { | ||
const logger = new Logger({ level: 'debug' }); | ||
@@ -26,3 +25,3 @@ const tag = getDefaultTag(0); | ||
expect(ctx.topic).toBeDefined(); | ||
expect(ctx.topic.result).toEqual(TEST_RESULT); | ||
expect(ctx.topic.result).toEqual(step); | ||
done(); | ||
@@ -32,3 +31,4 @@ }, | ||
logger.addSubscriber(subscriber); | ||
logger.log('test', { topic: { stage: 'Executor', result: TEST_RESULT, step }, tag }); | ||
// FIXME | ||
// logger.log('test', <TExecutorMessageContext>{ topic: { stage: 'Executor', result: { step } }, tag }); | ||
}); | ||
@@ -35,0 +35,0 @@ }); |
@@ -38,3 +38,3 @@ import { TNamed, AStepper } from '../defs.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../defs.js").TStepResult, step: import("../defs.js").TVStep): Promise<void | import("../interfaces/logger.js").TMessageContext>; | ||
@@ -41,0 +41,0 @@ setWorld(world: import("../defs.js").TWorld, steppers: AStepper[]): Promise<void>; |
@@ -19,3 +19,3 @@ import { AStepper } from '../defs.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../defs.js").TStepResult, step: import("../defs.js").TVStep): Promise<void | import("../interfaces/logger.js").TMessageContext>; | ||
@@ -22,0 +22,0 @@ setWorld(world: import("../defs.js").TWorld, steppers: AStepper[]): Promise<void>; |
@@ -20,3 +20,3 @@ import { AStepper } from '../defs.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../defs.js").TStepResult, step: import("../defs.js").TVStep): Promise<void | import("../interfaces/logger.js").TMessageContext>; | ||
@@ -47,3 +47,3 @@ setWorld(world: import("../defs.js").TWorld, steppers: AStepper[]): Promise<void>; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../defs.js").TStepResult, step: import("../defs.js").TVStep): Promise<void | import("../interfaces/logger.js").TMessageContext>; | ||
@@ -50,0 +50,0 @@ setWorld(world: import("../defs.js").TWorld, steppers: AStepper[]): Promise<void>; |
@@ -17,4 +17,5 @@ import { TVStep, TResolvedFeature, TExecutorResult, TStepResult, TFeatureResult, TActionResult, TWorld, AStepper, TEndFeatureCallback, CStepper, TFound } from '../lib/defs.js'; | ||
onFailure(result: TStepResult, step: TVStep): Promise<void>; | ||
endFeature(featureResult: TFeatureResult): Promise<void>; | ||
endFeature(): Promise<void>; | ||
doEndFeatureCallback(featureResult: TFeatureResult): Promise<void>; | ||
close(): Promise<void>; | ||
} |
@@ -28,10 +28,9 @@ import { STAY, STAY_FAILURE, } from '../lib/defs.js'; | ||
ok = ok && featureResult.ok; | ||
const shouldClose = !stayOnFailure || ok; | ||
featureResults.push(featureResult); | ||
const shouldClose = ok || !stayOnFailure; | ||
await featureExecutor.endFeature(); // this should be before close | ||
if (shouldClose) { | ||
await featureExecutor.endFeature(featureResult); | ||
} | ||
if (shouldClose) { | ||
await featureExecutor.close(); | ||
} | ||
await featureExecutor.doEndFeatureCallback(featureResult); | ||
} | ||
@@ -77,3 +76,4 @@ return { ok, featureResults: featureResults, tag: world.tag, shared: world.shared }; | ||
} | ||
world.logger.log('✅', { topic: { stage: 'Executor', result, step } }); | ||
const indicator = result.ok ? '✅' : '❌'; | ||
world.logger.log(indicator, { topic: { stage: 'Executor', result, step } }); | ||
stepResults.push(result); | ||
@@ -115,3 +115,2 @@ if (!ok) { | ||
const res = await s.onFailure(result, step); | ||
console.log('\n\nres', res); | ||
this.world.logger.error(`onFailure from ${result.in} for ${s.constructor.name}`, res); | ||
@@ -121,9 +120,15 @@ } | ||
} | ||
async endFeature(featureResult) { | ||
async endFeature() { | ||
for (const s of this.steppers) { | ||
if (s.endFeature) { | ||
this.world.logger.debug(`endFeature ${s.constructor.name}`); | ||
await s.endFeature(); | ||
await s.endFeature().catch((error) => { | ||
console.error('endFeature', error); | ||
throw (error); | ||
}); | ||
this.world.logger.debug(`endedFeature ${s.constructor.name}`); | ||
} | ||
} | ||
} | ||
async doEndFeatureCallback(featureResult) { | ||
if (this.endFeatureCallback) { | ||
@@ -130,0 +135,0 @@ try { |
@@ -12,3 +12,3 @@ import { AStepper } from '../lib/defs.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../lib/defs.js").TStepResult, step: import("../lib/defs.js").TVStep): Promise<void | import("../lib/interfaces/logger.js").TMessageContext>; | ||
@@ -15,0 +15,0 @@ setWorld(world: import("../lib/defs.js").TWorld, steppers: AStepper[]): Promise<void>; |
@@ -20,3 +20,3 @@ import { TNamed, AStepper } from '../lib/defs.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../lib/defs.js").TStepResult, step: import("../lib/defs.js").TVStep): Promise<void | import("../lib/interfaces/logger.js").TMessageContext>; | ||
@@ -23,0 +23,0 @@ setWorld(world: import("../lib/defs.js").TWorld, steppers: AStepper[]): Promise<void>; |
@@ -61,3 +61,3 @@ import { TNamed, AStepper, TWorld, TVStep } from '../lib/defs.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../lib/defs.js").TStepResult, step: TVStep): Promise<void | import("../lib/interfaces/logger.js").TMessageContext>; | ||
@@ -64,0 +64,0 @@ getWorld(): TWorld; |
@@ -111,3 +111,3 @@ import { Context } from '../lib/contexts.js'; | ||
close?(): void; | ||
endFeature?(): void; | ||
endFeature?(): Promise<void>; | ||
onFailure?(result: import("../lib/defs.js").TStepResult, step: TVStep): Promise<void | import("../lib/interfaces/logger.js").TMessageContext>; | ||
@@ -114,0 +114,0 @@ setWorld(world: TWorld, steppers: AStepper[]): Promise<void>; |
@@ -34,3 +34,3 @@ import { DomainContext } from '../lib/contexts.js'; | ||
action: async (n, vstep) => { | ||
console.log('env', this.world.options.env); | ||
console.info('env', this.world.options.env); | ||
return await this.set(n, vstep); | ||
@@ -43,3 +43,3 @@ }, | ||
action: async (n, vstep) => { | ||
console.log('vars', this.world.shared); | ||
console.info('vars', this.world.shared); | ||
return await this.set(n, vstep); | ||
@@ -46,0 +46,0 @@ }, |
{ | ||
"name": "@haibun/core", | ||
"type": "module", | ||
"version": "1.31.0", | ||
"version": "1.31.1", | ||
"description": "", | ||
@@ -6,0 +6,0 @@ "author": "", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
299544
124
4200