testit-adapter-cypress 3.7.5

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.
Files changed (46) hide show
  1. package/README.md +240 -0
  2. package/dist/browser/commandLog.d.ts +10 -0
  3. package/dist/browser/commandLog.js +213 -0
  4. package/dist/browser/events/cypress.d.ts +2 -0
  5. package/dist/browser/events/cypress.js +38 -0
  6. package/dist/browser/events/index.d.ts +2 -0
  7. package/dist/browser/events/index.js +15 -0
  8. package/dist/browser/events/mocha.d.ts +3 -0
  9. package/dist/browser/events/mocha.js +80 -0
  10. package/dist/browser/index.d.ts +1 -0
  11. package/dist/browser/index.js +14 -0
  12. package/dist/browser/lifecycle.d.ts +21 -0
  13. package/dist/browser/lifecycle.js +227 -0
  14. package/dist/browser/patching.d.ts +5 -0
  15. package/dist/browser/patching.js +117 -0
  16. package/dist/browser/runtime.d.ts +31 -0
  17. package/dist/browser/runtime.js +284 -0
  18. package/dist/browser/serialize.d.ts +3 -0
  19. package/dist/browser/serialize.js +57 -0
  20. package/dist/browser/state.d.ts +28 -0
  21. package/dist/browser/state.js +80 -0
  22. package/dist/browser/steps.d.ts +14 -0
  23. package/dist/browser/steps.js +114 -0
  24. package/dist/browser/testplan.d.ts +2 -0
  25. package/dist/browser/testplan.js +55 -0
  26. package/dist/browser/types.d.ts +35 -0
  27. package/dist/browser/types.js +30 -0
  28. package/dist/browser/utils.d.ts +65 -0
  29. package/dist/browser/utils.js +187 -0
  30. package/dist/converter.d.ts +43 -0
  31. package/dist/converter.js +84 -0
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +6 -0
  34. package/dist/models/index.d.ts +0 -0
  35. package/dist/models/index.js +1 -0
  36. package/dist/models/status.d.ts +5 -0
  37. package/dist/models/status.js +9 -0
  38. package/dist/models/types.d.ts +280 -0
  39. package/dist/models/types.js +2 -0
  40. package/dist/node-utils.d.ts +15 -0
  41. package/dist/node-utils.js +93 -0
  42. package/dist/reporter.d.ts +24 -0
  43. package/dist/reporter.js +382 -0
  44. package/dist/utils.d.ts +17 -0
  45. package/dist/utils.js +34 -0
  46. package/package.json +50 -0
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeAsObject = void 0;
4
+ const state_js_1 = require("./state.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ exports.default = (value) => {
7
+ return isDomObject(value) ? stringifyAsDom(value) : (0, exports.serializeAsObject)(value);
8
+ };
9
+ const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10
+ const stripAncestorRefs = (value, ancestors = []) => {
11
+ if (!isPlainObject(value)) {
12
+ return value;
13
+ }
14
+ const result = {};
15
+ ancestors.push(value);
16
+ for (const [key, prop] of Object.entries(value)) {
17
+ if (typeof prop === "object" && prop !== null) {
18
+ if (ancestors.includes(prop)) {
19
+ continue;
20
+ }
21
+ result[key] = stripAncestorRefs(prop, ancestors);
22
+ }
23
+ else {
24
+ result[key] = prop;
25
+ }
26
+ }
27
+ ancestors.pop();
28
+ return result;
29
+ };
30
+ const serializeAsObject = (value) => {
31
+ if (isPlainObject(value)) {
32
+ const cleaned = stripAncestorRefs(value);
33
+ return (0, utils_js_1.serialize)({ ...cleaned }, getSerializeOptions());
34
+ }
35
+ return (0, utils_js_1.serialize)(value, getSerializeOptions());
36
+ };
37
+ exports.serializeAsObject = serializeAsObject;
38
+ const getSerializeOptions = () => {
39
+ const { stepsFromCommands: { maxArgumentDepth: maxDepth, maxArgumentLength: maxLength }, } = (0, state_js_1.getConfig)();
40
+ return { maxDepth, maxLength, replacer: nonNullReplacerWithDomSupport };
41
+ };
42
+ const isDomObject = (value) => typeof value === "object" && value !== null && Cypress.dom.isDom(value);
43
+ // @ts-ignore
44
+ const stringifyAsDom = (value) => Cypress.dom.stringify(value, "long");
45
+ const nonNullReplacerWithDomSupport = (_, value) => {
46
+ if (typeof value === "object") {
47
+ // Exclude null properties to make the result more compact.
48
+ if (value === null) {
49
+ return undefined;
50
+ }
51
+ if (Cypress.dom.isDom(value)) {
52
+ // Window, document, and DOM element properties are serialized with Cypress.dom.stringify.
53
+ return stringifyAsDom(value);
54
+ }
55
+ }
56
+ return value;
57
+ };
@@ -0,0 +1,28 @@
1
+ import type { TmsSpecState, CypressMessage, CypressTest, StepDescriptor, StepFinalizer } from "../models/types.js";
2
+ export declare const getTmsState: () => TmsSpecState;
3
+ export declare const isTmsInitialized: () => boolean;
4
+ export declare const setTmsInitialized: () => void;
5
+ export declare const getRuntimeMessages: () => CypressMessage[];
6
+ export declare const setRuntimeMessages: (value: CypressMessage[]) => void;
7
+ export declare const enqueueRuntimeMessage: (message: CypressMessage) => void;
8
+ export declare const getTmsTestPlan: () => import("../models/types.js").TestPlanV1 | null | undefined;
9
+ export declare const getProjectDir: () => string | undefined;
10
+ export declare const getCurrentTest: () => CypressTest | undefined;
11
+ export declare const setCurrentTest: (test: CypressTest) => void;
12
+ export declare const dropCurrentTest: () => void;
13
+ export declare const getConfig: () => {
14
+ stepsFromCommands: {
15
+ maxArgumentLength: number;
16
+ maxArgumentDepth: number;
17
+ };
18
+ };
19
+ export declare const getStepStack: () => StepDescriptor[];
20
+ export declare const getCurrentStep: () => StepDescriptor | undefined;
21
+ export declare const pushStep: (step: StepDescriptor) => number;
22
+ export declare const popStep: () => StepDescriptor | undefined;
23
+ export declare const popSteps: (index: number) => StepDescriptor[];
24
+ export declare const popAllSteps: () => StepDescriptor[];
25
+ export declare const clearStepStack: () => void;
26
+ export declare const setupStepFinalization: <T extends StepDescriptor>(step: T, finalizer?: StepFinalizer) => number;
27
+ export declare const getStepsToFinalize: () => [step: StepDescriptor, finalizer: StepFinalizer | undefined][];
28
+ export declare const clearStepsToFinalize: () => void;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearStepsToFinalize = exports.getStepsToFinalize = exports.setupStepFinalization = exports.clearStepStack = exports.popAllSteps = exports.popSteps = exports.popStep = exports.pushStep = exports.getCurrentStep = exports.getStepStack = exports.getConfig = exports.dropCurrentTest = exports.setCurrentTest = exports.getCurrentTest = exports.getProjectDir = exports.getTmsTestPlan = exports.enqueueRuntimeMessage = exports.setRuntimeMessages = exports.getRuntimeMessages = exports.setTmsInitialized = exports.isTmsInitialized = exports.getTmsState = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const getTmsState = () => {
6
+ let state = Cypress.env("tms");
7
+ if (!state) {
8
+ state = {
9
+ config: utils_js_1.DEFAULT_RUNTIME_CONFIG,
10
+ initialized: false,
11
+ messages: [],
12
+ testPlan: undefined,
13
+ currentTest: undefined,
14
+ projectDir: undefined,
15
+ stepStack: [],
16
+ stepsToFinalize: [],
17
+ nextApiStepId: 0,
18
+ };
19
+ Cypress.env("tms", state);
20
+ }
21
+ return state;
22
+ };
23
+ exports.getTmsState = getTmsState;
24
+ const isTmsInitialized = () => (0, exports.getTmsState)().initialized;
25
+ exports.isTmsInitialized = isTmsInitialized;
26
+ const setTmsInitialized = () => {
27
+ (0, exports.getTmsState)().initialized = true;
28
+ };
29
+ exports.setTmsInitialized = setTmsInitialized;
30
+ const getRuntimeMessages = () => (0, exports.getTmsState)().messages;
31
+ exports.getRuntimeMessages = getRuntimeMessages;
32
+ const setRuntimeMessages = (value) => {
33
+ (0, exports.getTmsState)().messages = value;
34
+ };
35
+ exports.setRuntimeMessages = setRuntimeMessages;
36
+ const enqueueRuntimeMessage = (message) => {
37
+ (0, exports.getRuntimeMessages)().push(message);
38
+ };
39
+ exports.enqueueRuntimeMessage = enqueueRuntimeMessage;
40
+ const getTmsTestPlan = () => (0, exports.getTmsState)().testPlan;
41
+ exports.getTmsTestPlan = getTmsTestPlan;
42
+ const getProjectDir = () => (0, exports.getTmsState)().projectDir;
43
+ exports.getProjectDir = getProjectDir;
44
+ const getCurrentTest = () => (0, exports.getTmsState)().currentTest;
45
+ exports.getCurrentTest = getCurrentTest;
46
+ const setCurrentTest = (test) => {
47
+ (0, exports.getTmsState)().currentTest = test;
48
+ };
49
+ exports.setCurrentTest = setCurrentTest;
50
+ const dropCurrentTest = () => {
51
+ (0, exports.getTmsState)().currentTest = undefined;
52
+ };
53
+ exports.dropCurrentTest = dropCurrentTest;
54
+ const getConfig = () => (0, exports.getTmsState)().config;
55
+ exports.getConfig = getConfig;
56
+ const getStepStack = () => (0, exports.getTmsState)().stepStack;
57
+ exports.getStepStack = getStepStack;
58
+ const getCurrentStep = () => (0, utils_js_1.last)((0, exports.getStepStack)());
59
+ exports.getCurrentStep = getCurrentStep;
60
+ const pushStep = (step) => (0, exports.getStepStack)().push(step);
61
+ exports.pushStep = pushStep;
62
+ const popStep = () => (0, exports.getStepStack)().pop();
63
+ exports.popStep = popStep;
64
+ const popSteps = (index) => (0, utils_js_1.toReversed)((0, exports.getStepStack)().splice(index));
65
+ exports.popSteps = popSteps;
66
+ const popAllSteps = () => (0, exports.popSteps)(0);
67
+ exports.popAllSteps = popAllSteps;
68
+ const clearStepStack = () => {
69
+ (0, exports.getTmsState)().stepStack = [];
70
+ };
71
+ exports.clearStepStack = clearStepStack;
72
+ const setupStepFinalization = (step, finalizer) => (0, exports.getTmsState)().stepsToFinalize.push([step, finalizer]);
73
+ exports.setupStepFinalization = setupStepFinalization;
74
+ const getStepsToFinalize = () => (0, exports.getTmsState)().stepsToFinalize;
75
+ exports.getStepsToFinalize = getStepsToFinalize;
76
+ const clearStepsToFinalize = () => {
77
+ const state = (0, exports.getTmsState)();
78
+ state.stepsToFinalize = [];
79
+ };
80
+ exports.clearStepsToFinalize = clearStepsToFinalize;
@@ -0,0 +1,14 @@
1
+ import type { StatusDetails } from "../models/types.js";
2
+ import type { ApiStepDescriptor, LogStepDescriptor, StepDescriptor } from "../models/types.js";
3
+ import { Status } from "../models/status.js";
4
+ export declare const TMS_STEP_CMD_SUBJECT: {};
5
+ export declare const isApiStep: (descriptor: StepDescriptor) => descriptor is ApiStepDescriptor;
6
+ export declare const isLogStep: (descriptor: StepDescriptor) => descriptor is LogStepDescriptor;
7
+ export declare const startTmsApiStep: (name: string) => void;
8
+ export declare const pushTmsStep: () => string;
9
+ export declare const reportStepError: (error: Error) => void;
10
+ export declare const stopCurrentTmsApiStep: (status?: Status, statusDetails?: StatusDetails) => void;
11
+ export declare const findAndStopStepWithSubsteps: (pred: (stepEntry: StepDescriptor) => boolean, status?: Status, statusDetails?: StatusDetails) => void;
12
+ export declare const stopAllSteps: (status?: Status, statusDetails?: StatusDetails) => void;
13
+ export declare const finalizeSteps: () => void;
14
+ export declare const resolveStepStatus: (step: StepDescriptor) => Status.FAILED | Status.PASSED;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveStepStatus = exports.finalizeSteps = exports.stopAllSteps = exports.findAndStopStepWithSubsteps = exports.stopCurrentTmsApiStep = exports.reportStepError = exports.pushTmsStep = exports.startTmsApiStep = exports.isLogStep = exports.isApiStep = exports.TMS_STEP_CMD_SUBJECT = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const lifecycle_js_1 = require("./lifecycle.js");
6
+ const state_js_1 = require("./state.js");
7
+ const utils_js_2 = require("./utils.js");
8
+ const status_js_1 = require("../models/status.js");
9
+ exports.TMS_STEP_CMD_SUBJECT = {};
10
+ const isApiStep = (descriptor) => {
11
+ return descriptor.type === "api";
12
+ };
13
+ exports.isApiStep = isApiStep;
14
+ const isLogStep = (descriptor) => {
15
+ return descriptor.type === "log";
16
+ };
17
+ exports.isLogStep = isLogStep;
18
+ const startTmsApiStep = (name) => (0, lifecycle_js_1.reportStepStart)((0, exports.pushTmsStep)(), name);
19
+ exports.startTmsApiStep = startTmsApiStep;
20
+ const pushTmsStep = () => {
21
+ const id = (0, utils_js_2.generateApiStepId)();
22
+ (0, state_js_1.pushStep)({ id, type: "api" });
23
+ return id;
24
+ };
25
+ exports.pushTmsStep = pushTmsStep;
26
+ const reportStepError = (error) => {
27
+ const status = status_js_1.Status.FAILED;
28
+ const statusDetails = (0, utils_js_2.getMessageAndTraceFromError)(error);
29
+ // Cypress will abort the test/hook execution soon. No subsequent commands will be run, including the ones that
30
+ // have been scheduled by `testit.step` to stop the currently running steps.
31
+ // Additionally, we can't tell in advance if the current command log steps will be stopped normally or not.
32
+ //
33
+ // Given that, this function will stop all consecutive Tms API steps at the tip of the step stack.
34
+ // The command log steps will be given a chance to stop normally to get the most correct timings.
35
+ //
36
+ // The command log steps that won't stop normally (and Tms API substeps thereof) will be stopped during the
37
+ // test/hook finalization phase.
38
+ stopTmsApiStepStackTip(status, statusDetails);
39
+ // It's not guaranteed for command log steps and intermediate Tms API steps to have access to the error at the
40
+ // moment they are stopped.
41
+ // Additionally, Cypress may not update the stack trace of the error at that time. Until that happens, the stack
42
+ // trace points deep in the bundled code, which is little to no use for the user. Therefore, we need to associate
43
+ // the remaining steps with the error object to grab the updated stack trace later.
44
+ associateErrorWithRunningSteps(error);
45
+ };
46
+ exports.reportStepError = reportStepError;
47
+ const stopCurrentTmsApiStep = (status, statusDetails) => (0, exports.findAndStopStepWithSubsteps)((stepDescriptor) => (0, exports.isApiStep)(stepDescriptor), status, statusDetails);
48
+ exports.stopCurrentTmsApiStep = stopCurrentTmsApiStep;
49
+ const findAndStopStepWithSubsteps = (pred, status, statusDetails) => stopSelectedSteps((0, utils_js_1.popUntilFindIncluded)((0, state_js_1.getStepStack)(), pred), status, statusDetails);
50
+ exports.findAndStopStepWithSubsteps = findAndStopStepWithSubsteps;
51
+ const stopAllSteps = (status, statusDetails) => stopSelectedSteps((0, state_js_1.popAllSteps)(), status, statusDetails);
52
+ exports.stopAllSteps = stopAllSteps;
53
+ const finalizeSteps = () => {
54
+ // This will stop all dangling steps (like log groups with missing endGroup calls or logs that haven't been
55
+ // finished by Cypress due to an error).
56
+ (0, exports.stopAllSteps)();
57
+ (0, state_js_1.getStepsToFinalize)().forEach(finalizeOneStep);
58
+ (0, state_js_1.clearStepsToFinalize)();
59
+ };
60
+ exports.finalizeSteps = finalizeSteps;
61
+ const resolveStepStatus = (step) => step.error ? status_js_1.Status.FAILED : status_js_1.Status.PASSED;
62
+ exports.resolveStepStatus = resolveStepStatus;
63
+ const finalizeOneStep = ([step, finalizer]) => {
64
+ const { id, error } = step;
65
+ const data = { id };
66
+ if (error) {
67
+ // Cypress rewrites the stack trace of an error to point to the location in the test file. Until then, the stack
68
+ // trace points inside the messy bundle, which is not helpful. There are circumstances when we can't be sure this
69
+ // has happened when a step is about to stop. That's why we defer setting the status details until we are sure
70
+ // Cypress does its job.
71
+ data.statusDetails = (0, utils_js_2.getMessageAndTraceFromError)(error);
72
+ }
73
+ finalizer?.(data);
74
+ (0, state_js_1.enqueueRuntimeMessage)({
75
+ type: "cypress_step_finalize",
76
+ data,
77
+ });
78
+ };
79
+ const stopTmsApiStepStackTip = (status, statusDetails) => {
80
+ const stepStack = (0, state_js_1.getStepStack)();
81
+ const firstApiStepAfterLastLogStep = stepStack.at(stepStack.findLastIndex(exports.isLogStep) + 1);
82
+ if (firstApiStepAfterLastLogStep) {
83
+ (0, exports.findAndStopStepWithSubsteps)((logEntryOrMessage) => Object.is(logEntryOrMessage, firstApiStepAfterLastLogStep), status, statusDetails);
84
+ }
85
+ };
86
+ const propagateErrorToStepDescriptor = (step, errorOfSubstep) => {
87
+ if ((0, exports.isLogStep)(step)) {
88
+ const error = step.log.attributes.error;
89
+ if (error) {
90
+ return (step.error = error);
91
+ }
92
+ }
93
+ if (errorOfSubstep) {
94
+ step.error = errorOfSubstep;
95
+ }
96
+ return step.error;
97
+ };
98
+ const stopSelectedSteps = (steps, status, statusDetails) => {
99
+ let error;
100
+ for (const stepEntry of steps) {
101
+ error = propagateErrorToStepDescriptor(stepEntry, error);
102
+ stopStep(stepEntry, status, statusDetails);
103
+ }
104
+ if (error) {
105
+ associateErrorWithRunningSteps(error);
106
+ }
107
+ };
108
+ const associateErrorWithRunningSteps = (error) => (0, state_js_1.getStepStack)().forEach((step) => (step.error = error));
109
+ const stopStep = (step, status, statusDetails) => {
110
+ (0, lifecycle_js_1.reportStepStop)(step, status, statusDetails);
111
+ if ((0, exports.isApiStep)(step) && step.error) {
112
+ (0, state_js_1.setupStepFinalization)(step);
113
+ }
114
+ };
@@ -0,0 +1,2 @@
1
+ import type { CypressSuite } from "../models/types.js";
2
+ export declare const applyTestPlan: (spec: Cypress.Spec, root: CypressSuite) => void;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyTestPlan = void 0;
4
+ const utils_js_1 = require("./utils.js");
5
+ const testit_js_commons_1 = require("testit-js-commons");
6
+ const applyTestPlan = (spec, root) => {
7
+ const testsInRun = Cypress.env("tmsTestsInRun") ?? undefined;
8
+ if (!testsInRun || !testsInRun.length)
9
+ return;
10
+ const specPath = (0, utils_js_1.resolveSpecRelativePath)(spec);
11
+ let testsBefore = 0;
12
+ for (const suite of iterateSuites(root)) {
13
+ testsBefore += suite.tests.length;
14
+ }
15
+ for (const suite of iterateSuites(root)) {
16
+ const indicesToRemove = getIndicesOfDeselectedTests(testsInRun, specPath, suite.tests);
17
+ removeSortedIndices(suite.tests, indicesToRemove);
18
+ }
19
+ let testsAfter = 0;
20
+ for (const suite of iterateSuites(root)) {
21
+ testsAfter += suite.tests.length;
22
+ }
23
+ if (testsBefore > 0 && testsAfter === 0) {
24
+ throw new Error("[testit-adapter-cypress] No Cypress tests matched externalIds from tests in run. ");
25
+ }
26
+ };
27
+ exports.applyTestPlan = applyTestPlan;
28
+ const iterateSuites = function* (parent) {
29
+ const suiteStack = [];
30
+ for (let s = parent; s; s = suiteStack.pop()) {
31
+ yield s;
32
+ // Pushing in reverse allows us to maintain depth-first pre-order traversal -
33
+ // the same order as used by Mocha & Cypress.
34
+ for (let i = s.suites.length - 1; i >= 0; i--) {
35
+ suiteStack.push(s.suites[i]);
36
+ }
37
+ }
38
+ };
39
+ const getIndicesOfDeselectedTests = (testsInRun, specPath, tests) => {
40
+ const indicesToRemove = [];
41
+ tests.forEach((test, index) => {
42
+ const { fullNameSuffix } = (0, utils_js_1.getTestMetadata)(test);
43
+ const fullName = `${specPath}#${fullNameSuffix}`;
44
+ const externalId = testit_js_commons_1.Utils.getHash(fullName);
45
+ if (!testsInRun.includes(externalId)) {
46
+ indicesToRemove.push(index);
47
+ }
48
+ });
49
+ return indicesToRemove;
50
+ };
51
+ const removeSortedIndices = (arr, indices) => {
52
+ for (let i = indices.length - 1; i >= 0; i--) {
53
+ arr.splice(indices[i], 1);
54
+ }
55
+ };
@@ -0,0 +1,35 @@
1
+ import type { StatusDetails } from "../models/types.js";
2
+ import { Label, Link, Status } from "testit-js-commons";
3
+ export declare enum ContentType {
4
+ PNG = "image/png",
5
+ MP4 = "video/mp4",
6
+ JSON = "application/json",
7
+ TEXT = "text/plain"
8
+ }
9
+ export interface AttachmentOptions {
10
+ contentType: ContentType | string;
11
+ encoding?: BufferEncoding;
12
+ fileExtension?: string;
13
+ path?: string;
14
+ body?: Buffer;
15
+ }
16
+ export interface TestRuntime {
17
+ addLabels(...labels: Label[]): PromiseLike<void>;
18
+ addTags(...tags: String[]): PromiseLike<void>;
19
+ addLinks(...links: Link[]): PromiseLike<void>;
20
+ addWorkItemIds(...workItemIds: string[]): PromiseLike<void>;
21
+ addParameter(name: string, value: string): PromiseLike<void>;
22
+ addDescription(markdown: string): PromiseLike<void>;
23
+ addTitle(markdown: string): PromiseLike<void>;
24
+ addDisplayName(name: string): PromiseLike<void>;
25
+ addAttachments(name: string, content: Buffer | string, options: AttachmentOptions): PromiseLike<void>;
26
+ addAttachmentsFromPath(name: string, path: string, options: Omit<AttachmentOptions, "encoding">): PromiseLike<void>;
27
+ addGlobalAttachments(name: string, content: Buffer | string, options: AttachmentOptions): PromiseLike<void>;
28
+ addGlobalAttachmentsFromPath(name: string, path: string, options: Omit<AttachmentOptions, "encoding">): PromiseLike<void>;
29
+ addMessage(details: StatusDetails): PromiseLike<void>;
30
+ logStep(name: string, status?: Status, error?: Error): PromiseLike<void>;
31
+ step<T>(name: string, body: () => T | PromiseLike<T>): PromiseLike<T>;
32
+ stepDisplayName(name: string): PromiseLike<void>;
33
+ stepParameter(name: string, value: string): PromiseLike<void>;
34
+ }
35
+ export declare const noopRuntime: TestRuntime;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noopRuntime = exports.ContentType = void 0;
4
+ var ContentType;
5
+ (function (ContentType) {
6
+ ContentType["PNG"] = "image/png";
7
+ ContentType["MP4"] = "video/mp4";
8
+ ContentType["JSON"] = "application/json";
9
+ ContentType["TEXT"] = "text/plain";
10
+ })(ContentType || (exports.ContentType = ContentType = {}));
11
+ const noop = { then: () => noop, catch: () => noop };
12
+ exports.noopRuntime = {
13
+ addLabels: () => noop,
14
+ addTags: () => noop,
15
+ addLinks: () => noop,
16
+ addWorkItemIds: () => noop,
17
+ addParameter: () => noop,
18
+ addDescription: () => noop,
19
+ addTitle: () => noop,
20
+ addDisplayName: () => noop,
21
+ addAttachments: () => noop,
22
+ addAttachmentsFromPath: () => noop,
23
+ addGlobalAttachments: () => noop,
24
+ addGlobalAttachmentsFromPath: () => noop,
25
+ addMessage: () => noop,
26
+ logStep: () => noop,
27
+ step: (_, body) => Promise.resolve(body()),
28
+ stepDisplayName: () => noop,
29
+ stepParameter: () => noop,
30
+ };
@@ -0,0 +1,65 @@
1
+ import { Status } from "testit-js-commons";
2
+ import type { CypressConsoleProps, CypressHook, CypressLogEntry, CypressRenderProps, CypressSuite, CypressTest, StepDescriptor, StatusDetails } from "../models/types.js";
3
+ import { TestRuntime } from "./types.js";
4
+ export declare const getFileNameFromPath: (path: string) => string;
5
+ export declare const resolveSpecRelativePath: (spec: Cypress.Spec) => string;
6
+ export declare const uint8ArrayToBase64: (data: unknown) => string;
7
+ export declare const getTestStartData: (test: CypressTest) => {
8
+ start: number;
9
+ name: string;
10
+ fullNameSuffix: string;
11
+ };
12
+ export declare const getTestStopData: (test: CypressTest) => {
13
+ duration: number;
14
+ retries: any;
15
+ };
16
+ export declare const getTestSkipData: () => {
17
+ statusDetails: {
18
+ message: string;
19
+ };
20
+ };
21
+ export declare const getStepStopData: (step: StepDescriptor, status?: Status, statusDetails?: StatusDetails) => {
22
+ id: string;
23
+ status: Status;
24
+ statusDetails?: StatusDetails;
25
+ stop: number;
26
+ };
27
+ export declare const markTestAsReported: (test: CypressTest) => void;
28
+ export declare const isTestReported: (test: CypressTest) => boolean;
29
+ export declare const iterateSuites: (parent: CypressSuite) => Generator<CypressSuite, void, unknown>;
30
+ export declare const iterateTests: (parent: CypressSuite) => Generator<Mocha.Test & {
31
+ wallClockStartedAt?: Date;
32
+ parent: CypressSuite | undefined;
33
+ }, void, unknown>;
34
+ export declare const getSuitePath: (test: CypressTest) => CypressSuite[];
35
+ export declare const getSuiteTitlePath: (test: CypressTest) => string[];
36
+ export declare const generateApiStepId: () => string;
37
+ export declare const getTestMetadata: (test: CypressTest) => {
38
+ name: string;
39
+ fullNameSuffix: string;
40
+ };
41
+ export declare const isTmsHook: (hook: CypressHook) => boolean;
42
+ export declare const isRootAfterAllHook: (hook: CypressHook) => boolean;
43
+ export declare const isLastRootAfterHook: (context: Mocha.Context) => boolean;
44
+ export declare const getStatusDataOfTestSkippedByHookError: (hookTitle: string, isEachHook: boolean, err: Error, suite: CypressSuite) => {
45
+ status: Status;
46
+ statusDetails: {
47
+ message: string | undefined;
48
+ trace: string | undefined;
49
+ };
50
+ };
51
+ export declare const resolveConsoleProps: (entry: CypressLogEntry) => CypressConsoleProps;
52
+ export declare const resolveRenderProps: (entry: CypressLogEntry) => CypressRenderProps;
53
+ export declare const getMessageAndTraceFromError: (error: Error | {
54
+ message?: string;
55
+ stack?: string;
56
+ }) => StatusDetails;
57
+ export declare const isPromise: (obj: unknown) => obj is PromiseLike<unknown>;
58
+ export type SerializeOptions = {
59
+ maxDepth?: number;
60
+ maxLength?: number;
61
+ replacer?: (key: string, value: unknown) => unknown;
62
+ };
63
+ export declare const serialize: (value: unknown, opts?: SerializeOptions) => string;
64
+ export declare const setGlobalTestRuntime: (r: TestRuntime) => void;
65
+ export declare const getGlobalTestRuntime: () => TestRuntime;