allure-js-commons 3.0.9 → 3.2.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.
@@ -1,2 +1,2 @@
1
1
  export type { AllureResults, Category, EnvironmentInfo, ExecutorInfo, RuntimeMessage, RuntimeMetadataMessage, RuntimeAttachmentContentMessage, RuntimeAttachmentPathMessage, RuntimeStartStepMessage, RuntimeStepMetadataMessage, RuntimeStopStepMessage, TestPlanV1Test, TestPlanV1, } from "./types.js";
2
- export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi, serialize, } from "./utils.js";
2
+ export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, getMetadataLabel, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi, serialize, } from "./utils.js";
@@ -2,6 +2,46 @@
2
2
  import { type AttachmentOptions, type FixtureResult, type Label, type StepResult, type TestResult } from "../../model.js";
3
3
  import type { Category, EnvironmentInfo, RuntimeMessage } from "../types.js";
4
4
  import type { FixtureType, LinkConfig, ReporterRuntimeConfig, TestScope, Writer } from "./types.js";
5
+ export interface StepStack {
6
+ clear(): void;
7
+ removeRoot(rootUuid: string): void;
8
+ currentStep(rootUuid: string): string | undefined;
9
+ addStep(rootUuid: string, stepUuid: string): void;
10
+ removeStep(stepUuid: string): void;
11
+ }
12
+ /**
13
+ * Simpler steps stack implementation that contains only the current steps without root nodes
14
+ * Useful, when you need to create steps without binding them to a specific test or fixture
15
+ * @example
16
+ * ```js
17
+ * const stack = new ShallowStepsStack();
18
+ *
19
+ * stack.startStep({ name: "step 1" });
20
+ * stack.startStep({ name: "step 1.1" });
21
+ * stack.stopStep({ status: Status.FAILED });
22
+ * stack.stopStep({ status: Status.PASSED });
23
+ * stack.steps // => [{ name: "step 1", status: Status.PASSED, steps: [{ name: "step 1.1", status: Status.FAILED }] }]
24
+ * ```
25
+ */
26
+ export declare class ShallowStepsStack {
27
+ #private;
28
+ steps: StepResult[];
29
+ startStep(step: Partial<StepResult>): void;
30
+ updateStep(updateFunc: (result: StepResult) => void): void;
31
+ stopStep(opts?: {
32
+ stop?: number;
33
+ duration?: number;
34
+ }): void;
35
+ }
36
+ export declare class DefaultStepStack implements StepStack {
37
+ private stepsByRoot;
38
+ private rootsByStep;
39
+ clear: () => void;
40
+ removeRoot: (rootUuid: string) => void;
41
+ currentStep: (rootUuid: string) => string | undefined;
42
+ addStep: (rootUuid: string, stepUuid: string) => void;
43
+ removeStep(stepUuid: string): void;
44
+ }
5
45
  export declare class ReporterRuntime {
6
46
  #private;
7
47
  private readonly state;
@@ -12,7 +52,7 @@ export declare class ReporterRuntime {
12
52
  environmentInfo?: EnvironmentInfo;
13
53
  linkConfig?: LinkConfig;
14
54
  globalLabels: Label[];
15
- constructor({ writer, listeners, environmentInfo, categories, links, globalLabels }: ReporterRuntimeConfig);
55
+ constructor({ writer, listeners, environmentInfo, categories, links, globalLabels, }: ReporterRuntimeConfig);
16
56
  startScope: () => string;
17
57
  updateScope: (uuid: string, updateFunc: (scope: TestScope) => void) => void;
18
58
  writeScope: (uuid: string) => void;
@@ -4,7 +4,7 @@ export * from "./utils.js";
4
4
  export * from "./testplan.js";
5
5
  export * from "./factory.js";
6
6
  export { LifecycleState } from "./LifecycleState.js";
7
- export { ReporterRuntime } from "./ReporterRuntime.js";
7
+ export { type StepStack, DefaultStepStack, ReporterRuntime, ShallowStepsStack } from "./ReporterRuntime.js";
8
8
  export { InMemoryWriter } from "./writer/InMemoryWriter.js";
9
9
  export { FileSystemWriter } from "./writer/FileSystemWriter.js";
10
10
  export { MessageWriter } from "./writer/MessageWriter.js";
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { FixtureResult, Label, Link, LinkType, Parameter, StepResult, TestResult, TestResultContainer } from "../../model.js";
2
+ import type { FixtureResult, Label, LabelName, Link, LinkType, Parameter, StepResult, TestResult, TestResultContainer } from "../../model.js";
3
3
  import type { Category, EnvironmentInfo } from "../types.js";
4
4
  export declare const ALLURE_METADATA_CONTENT_TYPE = "application/vnd.allure.metadata+json";
5
5
  export declare const ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE = "application/vnd.allure.message+json";
@@ -22,10 +22,11 @@ export type LinkTypeOptions = {
22
22
  };
23
23
  export type LinkConfig<TOpts extends LinkTypeOptions = LinkTypeOptions> = Partial<Record<LinkType, TOpts>> & Record<string, TOpts>;
24
24
  export type WriterDescriptor = [cls: string, ...args: readonly unknown[]] | string;
25
+ export type GlobalLabelsConfig = Partial<Record<LabelName, string | string[]>> & Record<string, string | string[]>;
25
26
  export interface ReporterConfig {
26
27
  readonly resultsDir?: string;
27
28
  readonly links?: LinkConfig;
28
- readonly globalLabels?: Label[];
29
+ readonly globalLabels?: Label[] | GlobalLabelsConfig;
29
30
  readonly listeners?: LifecycleListener[];
30
31
  readonly environmentInfo?: EnvironmentInfo;
31
32
  readonly categories?: Category[];
@@ -1,4 +1,4 @@
1
- import type { FixtureResult, Label, StatusDetails, StepResult, TestResult } from "../model.js";
1
+ import type { FixtureResult, Label, Link, StatusDetails, StepResult, TestResult } from "../model.js";
2
2
  import { LabelName, Status } from "../model.js";
3
3
  import type { RuntimeMessage, SerializeOptions } from "./types.js";
4
4
  export declare const getStatusFromError: (error: Partial<Error>) => Status;
@@ -10,13 +10,27 @@ export declare const getMessageAndTraceFromError: (error: Error | {
10
10
  message?: string;
11
11
  stack?: string;
12
12
  }) => StatusDetails;
13
+ type AllureTitleMetadataMatch = RegExpMatchArray & {
14
+ groups: {
15
+ type?: string;
16
+ v1?: string;
17
+ v2?: string;
18
+ v3?: string;
19
+ v4?: string;
20
+ };
21
+ };
22
+ export declare const allureMetadataRegexp: RegExp;
23
+ export declare const allureTitleMetadataRegexp: RegExp;
24
+ export declare const allureTitleMetadataRegexpGlobal: RegExp;
13
25
  export declare const allureIdRegexp: RegExp;
14
- export declare const allureIdRegexpGlobal: RegExp;
15
26
  export declare const allureLabelRegexp: RegExp;
16
- export declare const allureLabelRegexpGlobal: RegExp;
27
+ export declare const getTypeFromAllureTitleMetadataMatch: (match: AllureTitleMetadataMatch) => string;
28
+ export declare const getValueFromAllureTitleMetadataMatch: (match: AllureTitleMetadataMatch) => string;
17
29
  export declare const isMetadataTag: (tag: string) => boolean;
30
+ export declare const getMetadataLabel: (tag: string, value?: string) => Label | undefined;
18
31
  export declare const extractMetadataFromString: (title: string) => {
19
32
  labels: Label[];
33
+ links: Link[];
20
34
  cleanTitle: string;
21
35
  };
22
36
  export declare const isAnyStepFailed: (item: StepResult | TestResult | FixtureResult) => boolean;
@@ -27,3 +41,4 @@ export declare const getStepsMessagesPair: (messages: RuntimeMessage[]) => Runti
27
41
  export declare const getUnfinishedStepsMessages: (messages: RuntimeMessage[]) => RuntimeMessage[][];
28
42
  export declare const isPromise: <T = any>(obj: any) => obj is PromiseLike<T>;
29
43
  export declare const serialize: (value: any, { maxDepth, maxLength, replacer }?: SerializeOptions) => string;
44
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allure-js-commons",
3
- "version": "3.0.9",
3
+ "version": "3.2.0",
4
4
  "description": "Allure JS Commons",
5
5
  "keywords": [
6
6
  "allure",
@@ -102,10 +102,10 @@
102
102
  "npm-run-all2": "^7.0.0",
103
103
  "rimraf": "^6.0.0",
104
104
  "typescript": "^5.2.2",
105
- "vitest": "^2.1.8"
105
+ "vitest": "^3.0.5"
106
106
  },
107
107
  "peerDependencies": {
108
- "allure-playwright": "3.0.9"
108
+ "allure-playwright": "3.2.0"
109
109
  },
110
110
  "peerDependenciesMeta": {
111
111
  "allure-playwright": {