@decaf-ts/utils 1.0.10 → 1.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.
Files changed (210) hide show
  1. package/README.md +1 -1
  2. package/dist/utils.cjs +1 -1
  3. package/dist/utils.cjs.map +1 -1
  4. package/dist/utils.js +1 -1
  5. package/dist/utils.js.map +1 -1
  6. package/lib/cjs/assets/slogans.cjs +3 -2
  7. package/lib/cjs/assets/slogans.cjs.map +1 -0
  8. package/lib/cjs/bin/build-scripts.cjs +5 -4
  9. package/lib/cjs/bin/build-scripts.cjs.map +1 -0
  10. package/lib/cjs/bin/release-chain-dispatch.cjs +5 -4
  11. package/lib/cjs/bin/release-chain-dispatch.cjs.map +1 -0
  12. package/lib/cjs/bin/release-chain.cjs +5 -4
  13. package/lib/cjs/bin/release-chain.cjs.map +1 -0
  14. package/lib/cjs/bin/tag-release.cjs +5 -4
  15. package/lib/cjs/bin/tag-release.cjs.map +1 -0
  16. package/lib/cjs/cli/command.cjs +11 -10
  17. package/lib/cjs/cli/command.cjs.map +1 -0
  18. package/lib/cjs/cli/commands/build-scripts.cjs +163 -44
  19. package/lib/cjs/cli/commands/build-scripts.cjs.map +1 -0
  20. package/lib/cjs/cli/commands/index.cjs +1 -0
  21. package/lib/cjs/cli/commands/index.cjs.map +1 -0
  22. package/lib/cjs/cli/commands/release-chain.cjs +12 -11
  23. package/lib/cjs/cli/commands/release-chain.cjs.map +1 -0
  24. package/lib/cjs/cli/commands/tag-release.cjs +21 -20
  25. package/lib/cjs/cli/commands/tag-release.cjs.map +1 -0
  26. package/lib/cjs/cli/constants.cjs +1 -0
  27. package/lib/cjs/cli/constants.cjs.map +1 -0
  28. package/lib/cjs/cli/index.cjs +1 -0
  29. package/lib/cjs/cli/index.cjs.map +1 -0
  30. package/lib/cjs/cli/types.cjs +1 -0
  31. package/lib/cjs/cli/types.cjs.map +1 -0
  32. package/lib/cjs/index.cjs +2 -1
  33. package/lib/cjs/index.cjs.map +1 -0
  34. package/lib/cjs/input/index.cjs +1 -0
  35. package/lib/cjs/input/index.cjs.map +1 -0
  36. package/lib/cjs/input/input.cjs +1 -0
  37. package/lib/cjs/input/input.cjs.map +1 -0
  38. package/lib/cjs/input/types.cjs +1 -0
  39. package/lib/cjs/input/types.cjs.map +1 -0
  40. package/lib/cjs/output/common.cjs +4 -3
  41. package/lib/cjs/output/common.cjs.map +1 -0
  42. package/lib/cjs/output/index.cjs +1 -0
  43. package/lib/cjs/output/index.cjs.map +1 -0
  44. package/lib/cjs/release-chain/index.cjs +1 -0
  45. package/lib/cjs/release-chain/index.cjs.map +1 -0
  46. package/lib/cjs/tests/Consumer.cjs +3 -2
  47. package/lib/cjs/tests/Consumer.cjs.map +1 -0
  48. package/lib/cjs/tests/ProducerChildProcess.cjs.map +1 -0
  49. package/lib/cjs/tests/TestReporter.cjs +5 -4
  50. package/lib/cjs/tests/TestReporter.cjs.map +1 -0
  51. package/lib/cjs/tests/index.cjs +1 -0
  52. package/lib/cjs/tests/index.cjs.map +1 -0
  53. package/lib/cjs/tests/jestPerformanceRunner.cjs +5 -4
  54. package/lib/cjs/tests/jestPerformanceRunner.cjs.map +1 -0
  55. package/lib/cjs/tests/utils.cjs +5 -4
  56. package/lib/cjs/tests/utils.cjs.map +1 -0
  57. package/lib/cjs/utils/constants.cjs +3 -16
  58. package/lib/cjs/utils/constants.cjs.map +1 -0
  59. package/lib/cjs/utils/fs.cjs +16 -15
  60. package/lib/cjs/utils/fs.cjs.map +1 -0
  61. package/lib/cjs/utils/http.cjs +1 -0
  62. package/lib/cjs/utils/http.cjs.map +1 -0
  63. package/lib/cjs/utils/index.cjs +1 -0
  64. package/lib/cjs/utils/index.cjs.map +1 -0
  65. package/lib/cjs/utils/md.cjs +1 -0
  66. package/lib/cjs/utils/md.cjs.map +1 -0
  67. package/lib/cjs/utils/performanceRunner.cjs +1 -0
  68. package/lib/cjs/utils/performanceRunner.cjs.map +1 -0
  69. package/lib/cjs/utils/timeout.cjs +1 -0
  70. package/lib/cjs/utils/timeout.cjs.map +1 -0
  71. package/lib/cjs/utils/types.cjs +1 -0
  72. package/lib/cjs/utils/types.cjs.map +1 -0
  73. package/lib/cjs/utils/utils.cjs +5 -4
  74. package/lib/cjs/utils/utils.cjs.map +1 -0
  75. package/lib/cjs/writers/OutputWriter.cjs +1 -0
  76. package/lib/cjs/writers/OutputWriter.cjs.map +1 -0
  77. package/lib/cjs/writers/RegexpOutputWriter.cjs +3 -2
  78. package/lib/cjs/writers/RegexpOutputWriter.cjs.map +1 -0
  79. package/lib/cjs/writers/StandardOutputWriter.cjs +3 -2
  80. package/lib/cjs/writers/StandardOutputWriter.cjs.map +1 -0
  81. package/lib/cjs/writers/index.cjs +1 -0
  82. package/lib/cjs/writers/index.cjs.map +1 -0
  83. package/lib/cjs/writers/types.cjs +1 -0
  84. package/lib/cjs/writers/types.cjs.map +1 -0
  85. package/lib/esm/cli/commands/build-scripts.js +142 -24
  86. package/lib/esm/cli/commands/build-scripts.js.map +1 -1
  87. package/lib/esm/index.js +1 -1
  88. package/lib/types/assets/slogans.d.cts +19 -0
  89. package/lib/types/assets/slogans.d.mts +19 -0
  90. package/lib/types/bin/build-scripts.d.cts +1 -0
  91. package/lib/types/bin/build-scripts.d.mts +1 -0
  92. package/lib/types/bin/release-chain-dispatch.d.cts +1 -0
  93. package/lib/types/bin/release-chain-dispatch.d.mts +1 -0
  94. package/lib/types/bin/release-chain.d.cts +1 -0
  95. package/lib/types/bin/release-chain.d.mts +1 -0
  96. package/lib/types/bin/tag-release.d.cts +1 -0
  97. package/lib/types/bin/tag-release.d.mts +1 -0
  98. package/lib/types/cli/command.d.cts +104 -0
  99. package/lib/types/cli/command.d.mts +104 -0
  100. package/lib/types/cli/commands/build-scripts.d.cts +148 -0
  101. package/lib/types/cli/commands/build-scripts.d.mts +148 -0
  102. package/lib/types/cli/commands/build-scripts.d.ts +5 -0
  103. package/lib/types/cli/commands/index.d.cts +3 -0
  104. package/lib/types/cli/commands/index.d.mts +3 -0
  105. package/lib/types/cli/commands/release-chain.d.cts +62 -0
  106. package/lib/types/cli/commands/release-chain.d.mts +62 -0
  107. package/lib/types/cli/commands/tag-release.d.cts +105 -0
  108. package/lib/types/cli/commands/tag-release.d.mts +105 -0
  109. package/lib/types/cli/constants.d.cts +75 -0
  110. package/lib/types/cli/constants.d.mts +75 -0
  111. package/lib/types/cli/index.d.cts +4 -0
  112. package/lib/types/cli/index.d.mts +4 -0
  113. package/lib/types/cli/types.d.cts +30 -0
  114. package/lib/types/cli/types.d.mts +30 -0
  115. package/lib/types/index.d.cts +38 -0
  116. package/lib/types/index.d.mts +38 -0
  117. package/lib/types/index.d.ts +1 -1
  118. package/lib/types/input/index.d.cts +2 -0
  119. package/lib/types/input/index.d.mts +2 -0
  120. package/lib/types/input/input.d.cts +517 -0
  121. package/lib/types/input/input.d.mts +517 -0
  122. package/lib/types/input/types.d.cts +159 -0
  123. package/lib/types/input/types.d.mts +159 -0
  124. package/lib/types/output/common.d.cts +53 -0
  125. package/lib/types/output/common.d.mts +53 -0
  126. package/lib/types/output/index.d.cts +1 -0
  127. package/lib/types/output/index.d.mts +1 -0
  128. package/lib/types/release-chain/index.d.cts +43 -0
  129. package/lib/types/release-chain/index.d.mts +43 -0
  130. package/lib/types/tests/Consumer.d.cts +151 -0
  131. package/lib/types/tests/Consumer.d.mts +151 -0
  132. package/lib/types/tests/ProducerChildProcess.d.cts +18 -0
  133. package/lib/types/tests/ProducerChildProcess.d.mts +18 -0
  134. package/lib/types/tests/TestReporter.d.cts +245 -0
  135. package/lib/types/tests/TestReporter.d.mts +245 -0
  136. package/lib/types/tests/index.d.cts +4 -0
  137. package/lib/types/tests/index.d.mts +4 -0
  138. package/lib/types/tests/jestPerformanceRunner.d.cts +37 -0
  139. package/lib/types/tests/jestPerformanceRunner.d.mts +37 -0
  140. package/lib/types/tests/utils.d.cts +5 -0
  141. package/lib/types/tests/utils.d.mts +5 -0
  142. package/lib/types/utils/constants.d.cts +65 -0
  143. package/lib/types/utils/constants.d.mts +65 -0
  144. package/lib/types/utils/fs.d.cts +259 -0
  145. package/lib/types/utils/fs.d.mts +259 -0
  146. package/lib/types/utils/http.d.cts +41 -0
  147. package/lib/types/utils/http.d.mts +41 -0
  148. package/lib/types/utils/index.d.cts +6 -0
  149. package/lib/types/utils/index.d.mts +6 -0
  150. package/lib/types/utils/md.d.cts +156 -0
  151. package/lib/types/utils/md.d.mts +156 -0
  152. package/lib/types/utils/performanceRunner.d.cts +129 -0
  153. package/lib/types/utils/performanceRunner.d.mts +129 -0
  154. package/lib/types/utils/timeout.d.cts +12 -0
  155. package/lib/types/utils/timeout.d.mts +12 -0
  156. package/lib/types/utils/types.d.cts +112 -0
  157. package/lib/types/utils/types.d.mts +112 -0
  158. package/lib/types/utils/utils.d.cts +133 -0
  159. package/lib/types/utils/utils.d.mts +133 -0
  160. package/lib/types/writers/OutputWriter.d.cts +49 -0
  161. package/lib/types/writers/OutputWriter.d.mts +49 -0
  162. package/lib/types/writers/RegexpOutputWriter.d.cts +110 -0
  163. package/lib/types/writers/RegexpOutputWriter.d.mts +110 -0
  164. package/lib/types/writers/StandardOutputWriter.d.cts +130 -0
  165. package/lib/types/writers/StandardOutputWriter.d.mts +130 -0
  166. package/lib/types/writers/index.d.cts +4 -0
  167. package/lib/types/writers/index.d.mts +4 -0
  168. package/lib/types/writers/types.d.cts +29 -0
  169. package/lib/types/writers/types.d.mts +29 -0
  170. package/package.json +14 -8
  171. package/lib/cjs/assets/slogans.js.map +0 -1
  172. package/lib/cjs/bin/build-scripts.js.map +0 -1
  173. package/lib/cjs/bin/release-chain-dispatch.js.map +0 -1
  174. package/lib/cjs/bin/release-chain.js.map +0 -1
  175. package/lib/cjs/bin/tag-release.js.map +0 -1
  176. package/lib/cjs/cli/command.js.map +0 -1
  177. package/lib/cjs/cli/commands/build-scripts.js.map +0 -1
  178. package/lib/cjs/cli/commands/index.js.map +0 -1
  179. package/lib/cjs/cli/commands/release-chain.js.map +0 -1
  180. package/lib/cjs/cli/commands/tag-release.js.map +0 -1
  181. package/lib/cjs/cli/constants.js.map +0 -1
  182. package/lib/cjs/cli/index.js.map +0 -1
  183. package/lib/cjs/cli/types.js.map +0 -1
  184. package/lib/cjs/index.js.map +0 -1
  185. package/lib/cjs/input/index.js.map +0 -1
  186. package/lib/cjs/input/input.js.map +0 -1
  187. package/lib/cjs/input/types.js.map +0 -1
  188. package/lib/cjs/output/common.js.map +0 -1
  189. package/lib/cjs/output/index.js.map +0 -1
  190. package/lib/cjs/release-chain/index.js.map +0 -1
  191. package/lib/cjs/tests/Consumer.js.map +0 -1
  192. package/lib/cjs/tests/ProducerChildProcess.js.map +0 -1
  193. package/lib/cjs/tests/TestReporter.js.map +0 -1
  194. package/lib/cjs/tests/index.js.map +0 -1
  195. package/lib/cjs/tests/jestPerformanceRunner.js.map +0 -1
  196. package/lib/cjs/tests/utils.js.map +0 -1
  197. package/lib/cjs/utils/constants.js.map +0 -1
  198. package/lib/cjs/utils/fs.js.map +0 -1
  199. package/lib/cjs/utils/http.js.map +0 -1
  200. package/lib/cjs/utils/index.js.map +0 -1
  201. package/lib/cjs/utils/md.js.map +0 -1
  202. package/lib/cjs/utils/performanceRunner.js.map +0 -1
  203. package/lib/cjs/utils/timeout.js.map +0 -1
  204. package/lib/cjs/utils/types.js.map +0 -1
  205. package/lib/cjs/utils/utils.js.map +0 -1
  206. package/lib/cjs/writers/OutputWriter.js.map +0 -1
  207. package/lib/cjs/writers/RegexpOutputWriter.js.map +0 -1
  208. package/lib/cjs/writers/StandardOutputWriter.js.map +0 -1
  209. package/lib/cjs/writers/index.js.map +0 -1
  210. package/lib/cjs/writers/types.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ type ParentMessage = {
2
+ identifier: number;
3
+ action: string;
4
+ timeout?: number;
5
+ times: number;
6
+ random?: boolean;
7
+ terminate?: boolean;
8
+ };
9
+ type ProducerResponse = {
10
+ identifier: number;
11
+ action: string;
12
+ timeout?: number;
13
+ times: number;
14
+ random?: boolean;
15
+ result?: string[];
16
+ };
17
+ declare let shuttingDown: boolean;
18
+ declare const completeAndExit: (logMessage?: string) => void;
@@ -0,0 +1,245 @@
1
+ import { MdTableDefinition } from "../utils/md.cjs";
2
+ /**
3
+ * @interface AddAttachParams
4
+ * @description Parameters for adding an attachment to a report
5
+ * @summary Interface for attachment parameters
6
+ * @memberOf module:utils
7
+ */
8
+ export interface AddAttachParams {
9
+ attach: string | Buffer;
10
+ description: string | object;
11
+ context?: any;
12
+ bufferFormat?: string;
13
+ }
14
+ /**
15
+ * @interface AddMsgParams
16
+ * @description Parameters for adding a message to a report
17
+ * @summary Interface for message parameters
18
+ * @memberOf module:utils
19
+ */
20
+ export interface AddMsgParams {
21
+ message: string | object;
22
+ context?: any;
23
+ }
24
+ /**
25
+ * @typedef {("json"|"image"|"text"|"md")} PayloadType
26
+ * @description Types of payloads that can be handled
27
+ * @summary Union type for payload types
28
+ * @memberOf module:utils
29
+ */
30
+ export type PayloadType = "json" | "image" | "text" | "md";
31
+ export type EvidenceData = {
32
+ name: string;
33
+ content: string | Buffer;
34
+ path: string;
35
+ };
36
+ /**
37
+ * @description Environment variable key for Jest HTML reporters temporary directory path
38
+ * @summary Constant defining the environment variable key for Jest HTML reporters
39
+ * @const JestReportersTempPathEnvKey
40
+ * @memberOf module:utils
41
+ */
42
+ export declare const JestReportersTempPathEnvKey = "JEST_HTML_REPORTERS_TEMP_DIR_PATH";
43
+ /**
44
+ * @description Environment variable key to enable file-based evidence storage
45
+ * @summary Constant defining the environment variable key for storage enablement
46
+ * @const TestReporterStorageEnabledEnvKey
47
+ * @memberOf module:utils
48
+ */
49
+ export declare const TestReporterStorageEnabledEnvKey = "TEST_REPORTER_STORAGE_ENABLED";
50
+ /**
51
+ * @description Environment variable key for the base path of evidence storage
52
+ * @summary Constant defining the environment variable key for storage path
53
+ * @const TestReporterStoragePathEnvKey
54
+ * @memberOf module:utils
55
+ */
56
+ export declare const TestReporterStoragePathEnvKey = "TEST_REPORTER_STORAGE_PATH";
57
+ /**
58
+ * @description Test reporting utility class for managing test results and evidence
59
+ * @summary A comprehensive test reporter that handles various types of test artifacts including messages,
60
+ * attachments, data, images, tables, and graphs. It provides methods to report and store test evidence
61
+ * in different formats and manages dependencies for reporting functionality.
62
+ *
63
+ * @template T - Type of data being reported
64
+ * @param {string} [testCase="tests"] - Name of the test case
65
+ * @param {string} [basePath] - Base path for storing test reports
66
+ * @class
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const reporter = new TestReporter('login-test');
71
+ *
72
+ * // Report test messages
73
+ * await reporter.reportMessage('Test Started', 'Login flow initiated');
74
+ *
75
+ * // Report test data
76
+ * await reporter.reportData('user-credentials', { username: 'test' }, 'json');
77
+ *
78
+ * // Report test results table
79
+ * await reporter.reportTable('test-results', {
80
+ * headers: ['Step', 'Status'],
81
+ * rows: [
82
+ * { Step: 'Login', Status: 'Pass' },
83
+ * { Step: 'Validation', Status: 'Pass' }
84
+ * ]
85
+ * });
86
+ *
87
+ * // Report test evidence
88
+ * await reporter.reportAttachment('Screenshot', screenshotBuffer);
89
+ * ```
90
+ *
91
+ * @mermaid
92
+ * sequenceDiagram
93
+ * participant Client
94
+ * participant TestReporter
95
+ * participant FileSystem
96
+ * participant Dependencies
97
+ *
98
+ * Client->>TestReporter: new TestReporter(testCase, basePath)
99
+ * TestReporter->>FileSystem: Create report directory
100
+ *
101
+ * alt Report Message
102
+ * Client->>TestReporter: reportMessage(title, message)
103
+ * TestReporter->>Dependencies: Import helpers
104
+ * TestReporter->>FileSystem: Store message
105
+ * else Report Data
106
+ * Client->>TestReporter: reportData(reference, data, type)
107
+ * TestReporter->>Dependencies: Process data
108
+ * TestReporter->>FileSystem: Store formatted data
109
+ * else Report Table
110
+ * Client->>TestReporter: reportTable(reference, tableDef)
111
+ * TestReporter->>Dependencies: Convert to MD format
112
+ * TestReporter->>FileSystem: Store table
113
+ * end
114
+ */
115
+ export declare class TestReporter {
116
+ protected testCase: string;
117
+ protected basePath: string;
118
+ /**
119
+ * @description Function for adding messages to the test report
120
+ * @summary Static handler for processing and storing test messages
121
+ * @type {function(AddMsgParams): Promise<void>}
122
+ */
123
+ protected static addMsgFunction: (params: AddMsgParams) => Promise<void>;
124
+ /**
125
+ * @description Function for adding attachments to the test report
126
+ * @summary Static handler for processing and storing test attachments
127
+ * @type {function(AddAttachParams): Promise<void>}
128
+ */
129
+ protected static addAttachFunction: (params: AddAttachParams) => Promise<void>;
130
+ /**
131
+ * @description Map of dependencies required by the reporter
132
+ * @summary Stores the current state of dependencies
133
+ * @type {SimpleDependencyMap}
134
+ */
135
+ private deps?;
136
+ /**
137
+ * @description Checks if storage is enabled via environment variables
138
+ * @summary Static getter for storage enablement status
139
+ * @type {boolean}
140
+ */
141
+ static get storageEnabled(): boolean;
142
+ /**
143
+ * @description Gets the base path for evidence storage from environment variables or default
144
+ * @summary Static getter for evidence storage base path
145
+ * @type {string}
146
+ */
147
+ static get storagePath(): string;
148
+ constructor(testCase?: string, basePath?: string);
149
+ /**
150
+ * @description Retrieves all evidences for a given describe and it name
151
+ * @summary Searches the storage directory for matching evidences using string inclusion
152
+ * @param {string} describeName - Name of the describe block to match
153
+ * @param {string} itName - Name of the it block to match
154
+ * @return {EvidenceData[]} Array of matching evidences
155
+ */
156
+ static getEvidencesOf(describeName: string, itName: string): EvidenceData[];
157
+ /**
158
+ * @description Imports required helper functions
159
+ * @summary Ensures all necessary dependencies are available and imports helper functions
160
+ * @return {Promise<void>} Promise that resolves when helpers are imported
161
+ */
162
+ private importHelpers;
163
+ private getJestHtmlReportersTempDir;
164
+ private ensureJestHtmlReportersTempDirs;
165
+ private overrideJestHtmlReportersTempPaths;
166
+ /**
167
+ * @description Reports a message to the test report
168
+ * @summary Adds a formatted message to the test report with an optional title
169
+ * @param {string} title - Title of the message
170
+ * @param {string | object} message - Content of the message
171
+ * @return {Promise<void>} Promise that resolves when the message is reported
172
+ */
173
+ reportMessage(title: string, message: string | object): Promise<void>;
174
+ /**
175
+ * @description Reports an attachment to the test report
176
+ * @summary Adds a formatted message to the test report with an optional title
177
+ * @param {string} title - Title of the message
178
+ * @param {string | Buffer} attachment - Content of the message
179
+ * @return {Promise<void>} Promise that resolves when the message is reported
180
+ */
181
+ reportAttachment(title: string, attachment: string | Buffer): Promise<void>;
182
+ /**
183
+ * @description Reports data with specified type
184
+ * @summary Processes and stores data in the test report with formatting
185
+ * @param {string} reference - Reference identifier for the data
186
+ * @param {string | number | object} data - Data to be reported
187
+ * @param {PayloadType} type - Type of the payload
188
+ * @param {boolean} [trim=false] - Whether to trim the data
189
+ * @return {Promise<void>} Promise that resolves when data is reported
190
+ */
191
+ protected report(reference: string, data: string | number | object | Buffer, type: PayloadType, trim?: boolean): Promise<void>;
192
+ /**
193
+ * @description Stores evidence to a file in the specified directory structure
194
+ * @summary Internal method to handle file-based storage of test artifacts
195
+ * @param {string} reference - Reference identifier for the data
196
+ * @param {any} data - Data to be stored
197
+ * @param {PayloadType} type - Type of the payload
198
+ * @param {string} extension - File extension to use
199
+ * @return {Promise<void>}
200
+ */
201
+ private storeEvidence;
202
+ /**
203
+ * @description Reports data with a specified type
204
+ * @summary Wrapper method for reporting various types of data
205
+ * @param {string} reference - Reference identifier for the data
206
+ * @param {string | number | object} data - Data to be reported
207
+ * @param {PayloadType} [type="json"] - Type of the payload
208
+ * @param {boolean} [trim=false] - Whether to trim the data
209
+ * @return {Promise<void>} Promise that resolves when data is reported
210
+ */
211
+ reportData(reference: string, data: string | number | object, type?: PayloadType, trim?: boolean): Promise<void>;
212
+ /**
213
+ * @description Reports a JSON object
214
+ * @summary Convenience method for reporting JSON objects
215
+ * @param {string} reference - Reference identifier for the object
216
+ * @param {object} json - JSON object to be reported
217
+ * @param {boolean} [trim=false] - Whether to trim the object
218
+ * @return {Promise<void>} Promise that resolves when object is reported
219
+ */
220
+ reportObject(reference: string, json: object, trim?: boolean): Promise<void>;
221
+ /**
222
+ * @description Reports a table in markdown format
223
+ * @summary Converts and stores a table definition in markdown format
224
+ * @param {string} reference - Reference identifier for the table
225
+ * @param {MdTableDefinition} tableDef - Table definition object
226
+ * @return {Promise<void>} Promise that resolves when table is reported
227
+ */
228
+ reportTable(reference: string, tableDef: MdTableDefinition): Promise<void>;
229
+ /**
230
+ * @description Reports a graph using Chart.js
231
+ * @summary Generates and stores a graph visualization
232
+ * @param {string} reference - Reference identifier for the graph
233
+ * @param {any} config - Chart.js configuration object
234
+ * @return {Promise<void>} Promise that resolves when graph is reported
235
+ */
236
+ reportGraph(reference: string, config: any, width?: number, height?: number): Promise<Buffer>;
237
+ /**
238
+ * @description Reports an image to the test report
239
+ * @summary Stores an image buffer in the test report
240
+ * @param {string} reference - Reference identifier for the image
241
+ * @param {Buffer} buffer - Image data buffer
242
+ * @return {Promise<void>} Promise that resolves when image is reported
243
+ */
244
+ reportImage(reference: string, buffer: Buffer): Promise<void>;
245
+ }
@@ -0,0 +1,245 @@
1
+ import { MdTableDefinition } from "../utils/md.js";
2
+ /**
3
+ * @interface AddAttachParams
4
+ * @description Parameters for adding an attachment to a report
5
+ * @summary Interface for attachment parameters
6
+ * @memberOf module:utils
7
+ */
8
+ export interface AddAttachParams {
9
+ attach: string | Buffer;
10
+ description: string | object;
11
+ context?: any;
12
+ bufferFormat?: string;
13
+ }
14
+ /**
15
+ * @interface AddMsgParams
16
+ * @description Parameters for adding a message to a report
17
+ * @summary Interface for message parameters
18
+ * @memberOf module:utils
19
+ */
20
+ export interface AddMsgParams {
21
+ message: string | object;
22
+ context?: any;
23
+ }
24
+ /**
25
+ * @typedef {("json"|"image"|"text"|"md")} PayloadType
26
+ * @description Types of payloads that can be handled
27
+ * @summary Union type for payload types
28
+ * @memberOf module:utils
29
+ */
30
+ export type PayloadType = "json" | "image" | "text" | "md";
31
+ export type EvidenceData = {
32
+ name: string;
33
+ content: string | Buffer;
34
+ path: string;
35
+ };
36
+ /**
37
+ * @description Environment variable key for Jest HTML reporters temporary directory path
38
+ * @summary Constant defining the environment variable key for Jest HTML reporters
39
+ * @const JestReportersTempPathEnvKey
40
+ * @memberOf module:utils
41
+ */
42
+ export declare const JestReportersTempPathEnvKey = "JEST_HTML_REPORTERS_TEMP_DIR_PATH";
43
+ /**
44
+ * @description Environment variable key to enable file-based evidence storage
45
+ * @summary Constant defining the environment variable key for storage enablement
46
+ * @const TestReporterStorageEnabledEnvKey
47
+ * @memberOf module:utils
48
+ */
49
+ export declare const TestReporterStorageEnabledEnvKey = "TEST_REPORTER_STORAGE_ENABLED";
50
+ /**
51
+ * @description Environment variable key for the base path of evidence storage
52
+ * @summary Constant defining the environment variable key for storage path
53
+ * @const TestReporterStoragePathEnvKey
54
+ * @memberOf module:utils
55
+ */
56
+ export declare const TestReporterStoragePathEnvKey = "TEST_REPORTER_STORAGE_PATH";
57
+ /**
58
+ * @description Test reporting utility class for managing test results and evidence
59
+ * @summary A comprehensive test reporter that handles various types of test artifacts including messages,
60
+ * attachments, data, images, tables, and graphs. It provides methods to report and store test evidence
61
+ * in different formats and manages dependencies for reporting functionality.
62
+ *
63
+ * @template T - Type of data being reported
64
+ * @param {string} [testCase="tests"] - Name of the test case
65
+ * @param {string} [basePath] - Base path for storing test reports
66
+ * @class
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const reporter = new TestReporter('login-test');
71
+ *
72
+ * // Report test messages
73
+ * await reporter.reportMessage('Test Started', 'Login flow initiated');
74
+ *
75
+ * // Report test data
76
+ * await reporter.reportData('user-credentials', { username: 'test' }, 'json');
77
+ *
78
+ * // Report test results table
79
+ * await reporter.reportTable('test-results', {
80
+ * headers: ['Step', 'Status'],
81
+ * rows: [
82
+ * { Step: 'Login', Status: 'Pass' },
83
+ * { Step: 'Validation', Status: 'Pass' }
84
+ * ]
85
+ * });
86
+ *
87
+ * // Report test evidence
88
+ * await reporter.reportAttachment('Screenshot', screenshotBuffer);
89
+ * ```
90
+ *
91
+ * @mermaid
92
+ * sequenceDiagram
93
+ * participant Client
94
+ * participant TestReporter
95
+ * participant FileSystem
96
+ * participant Dependencies
97
+ *
98
+ * Client->>TestReporter: new TestReporter(testCase, basePath)
99
+ * TestReporter->>FileSystem: Create report directory
100
+ *
101
+ * alt Report Message
102
+ * Client->>TestReporter: reportMessage(title, message)
103
+ * TestReporter->>Dependencies: Import helpers
104
+ * TestReporter->>FileSystem: Store message
105
+ * else Report Data
106
+ * Client->>TestReporter: reportData(reference, data, type)
107
+ * TestReporter->>Dependencies: Process data
108
+ * TestReporter->>FileSystem: Store formatted data
109
+ * else Report Table
110
+ * Client->>TestReporter: reportTable(reference, tableDef)
111
+ * TestReporter->>Dependencies: Convert to MD format
112
+ * TestReporter->>FileSystem: Store table
113
+ * end
114
+ */
115
+ export declare class TestReporter {
116
+ protected testCase: string;
117
+ protected basePath: string;
118
+ /**
119
+ * @description Function for adding messages to the test report
120
+ * @summary Static handler for processing and storing test messages
121
+ * @type {function(AddMsgParams): Promise<void>}
122
+ */
123
+ protected static addMsgFunction: (params: AddMsgParams) => Promise<void>;
124
+ /**
125
+ * @description Function for adding attachments to the test report
126
+ * @summary Static handler for processing and storing test attachments
127
+ * @type {function(AddAttachParams): Promise<void>}
128
+ */
129
+ protected static addAttachFunction: (params: AddAttachParams) => Promise<void>;
130
+ /**
131
+ * @description Map of dependencies required by the reporter
132
+ * @summary Stores the current state of dependencies
133
+ * @type {SimpleDependencyMap}
134
+ */
135
+ private deps?;
136
+ /**
137
+ * @description Checks if storage is enabled via environment variables
138
+ * @summary Static getter for storage enablement status
139
+ * @type {boolean}
140
+ */
141
+ static get storageEnabled(): boolean;
142
+ /**
143
+ * @description Gets the base path for evidence storage from environment variables or default
144
+ * @summary Static getter for evidence storage base path
145
+ * @type {string}
146
+ */
147
+ static get storagePath(): string;
148
+ constructor(testCase?: string, basePath?: string);
149
+ /**
150
+ * @description Retrieves all evidences for a given describe and it name
151
+ * @summary Searches the storage directory for matching evidences using string inclusion
152
+ * @param {string} describeName - Name of the describe block to match
153
+ * @param {string} itName - Name of the it block to match
154
+ * @return {EvidenceData[]} Array of matching evidences
155
+ */
156
+ static getEvidencesOf(describeName: string, itName: string): EvidenceData[];
157
+ /**
158
+ * @description Imports required helper functions
159
+ * @summary Ensures all necessary dependencies are available and imports helper functions
160
+ * @return {Promise<void>} Promise that resolves when helpers are imported
161
+ */
162
+ private importHelpers;
163
+ private getJestHtmlReportersTempDir;
164
+ private ensureJestHtmlReportersTempDirs;
165
+ private overrideJestHtmlReportersTempPaths;
166
+ /**
167
+ * @description Reports a message to the test report
168
+ * @summary Adds a formatted message to the test report with an optional title
169
+ * @param {string} title - Title of the message
170
+ * @param {string | object} message - Content of the message
171
+ * @return {Promise<void>} Promise that resolves when the message is reported
172
+ */
173
+ reportMessage(title: string, message: string | object): Promise<void>;
174
+ /**
175
+ * @description Reports an attachment to the test report
176
+ * @summary Adds a formatted message to the test report with an optional title
177
+ * @param {string} title - Title of the message
178
+ * @param {string | Buffer} attachment - Content of the message
179
+ * @return {Promise<void>} Promise that resolves when the message is reported
180
+ */
181
+ reportAttachment(title: string, attachment: string | Buffer): Promise<void>;
182
+ /**
183
+ * @description Reports data with specified type
184
+ * @summary Processes and stores data in the test report with formatting
185
+ * @param {string} reference - Reference identifier for the data
186
+ * @param {string | number | object} data - Data to be reported
187
+ * @param {PayloadType} type - Type of the payload
188
+ * @param {boolean} [trim=false] - Whether to trim the data
189
+ * @return {Promise<void>} Promise that resolves when data is reported
190
+ */
191
+ protected report(reference: string, data: string | number | object | Buffer, type: PayloadType, trim?: boolean): Promise<void>;
192
+ /**
193
+ * @description Stores evidence to a file in the specified directory structure
194
+ * @summary Internal method to handle file-based storage of test artifacts
195
+ * @param {string} reference - Reference identifier for the data
196
+ * @param {any} data - Data to be stored
197
+ * @param {PayloadType} type - Type of the payload
198
+ * @param {string} extension - File extension to use
199
+ * @return {Promise<void>}
200
+ */
201
+ private storeEvidence;
202
+ /**
203
+ * @description Reports data with a specified type
204
+ * @summary Wrapper method for reporting various types of data
205
+ * @param {string} reference - Reference identifier for the data
206
+ * @param {string | number | object} data - Data to be reported
207
+ * @param {PayloadType} [type="json"] - Type of the payload
208
+ * @param {boolean} [trim=false] - Whether to trim the data
209
+ * @return {Promise<void>} Promise that resolves when data is reported
210
+ */
211
+ reportData(reference: string, data: string | number | object, type?: PayloadType, trim?: boolean): Promise<void>;
212
+ /**
213
+ * @description Reports a JSON object
214
+ * @summary Convenience method for reporting JSON objects
215
+ * @param {string} reference - Reference identifier for the object
216
+ * @param {object} json - JSON object to be reported
217
+ * @param {boolean} [trim=false] - Whether to trim the object
218
+ * @return {Promise<void>} Promise that resolves when object is reported
219
+ */
220
+ reportObject(reference: string, json: object, trim?: boolean): Promise<void>;
221
+ /**
222
+ * @description Reports a table in markdown format
223
+ * @summary Converts and stores a table definition in markdown format
224
+ * @param {string} reference - Reference identifier for the table
225
+ * @param {MdTableDefinition} tableDef - Table definition object
226
+ * @return {Promise<void>} Promise that resolves when table is reported
227
+ */
228
+ reportTable(reference: string, tableDef: MdTableDefinition): Promise<void>;
229
+ /**
230
+ * @description Reports a graph using Chart.js
231
+ * @summary Generates and stores a graph visualization
232
+ * @param {string} reference - Reference identifier for the graph
233
+ * @param {any} config - Chart.js configuration object
234
+ * @return {Promise<void>} Promise that resolves when graph is reported
235
+ */
236
+ reportGraph(reference: string, config: any, width?: number, height?: number): Promise<Buffer>;
237
+ /**
238
+ * @description Reports an image to the test report
239
+ * @summary Stores an image buffer in the test report
240
+ * @param {string} reference - Reference identifier for the image
241
+ * @param {Buffer} buffer - Image data buffer
242
+ * @return {Promise<void>} Promise that resolves when image is reported
243
+ */
244
+ reportImage(reference: string, buffer: Buffer): Promise<void>;
245
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./Consumer.cjs";
2
+ export * from "./TestReporter.cjs";
3
+ export * from "./utils.cjs";
4
+ export * from "./jestPerformanceRunner.cjs";
@@ -0,0 +1,4 @@
1
+ export * from "./Consumer.js";
2
+ export * from "./TestReporter.js";
3
+ export * from "./utils.js";
4
+ export * from "./jestPerformanceRunner.js";
@@ -0,0 +1,37 @@
1
+ import { PerformanceScenario, PerformanceRunner, PhaseResult } from "../utils/performanceRunner.cjs";
2
+ export type JestPerformanceScenario<TContext = Record<string, unknown>> = PerformanceScenario<TContext>;
3
+ export declare class JestPerformanceRunner<TContext = Record<string, unknown>> extends PerformanceRunner<TContext> {
4
+ protected scenario: JestPerformanceScenario<TContext>;
5
+ private readonly reporter;
6
+ constructor(scenario: JestPerformanceScenario<TContext>);
7
+ /** Disable the base-class text-table canvas; we render a proper bar chart instead. */
8
+ protected shouldRenderCanvas(): boolean;
9
+ /** Logs per-phase table to the jest-html-reporters attachment. */
10
+ private reportPhaseToReporter;
11
+ /**
12
+ * After all phases finish: console-log the combined summary (base class),
13
+ * then report the summary table and a bar chart with the reporter.
14
+ */
15
+ protected logSummary(results: PhaseResult<TContext>[]): Promise<void>;
16
+ private buildTableDef;
17
+ /**
18
+ * Builds a Chart.js config: grouped bar columns (Wall/Avg/Min/Max ms)
19
+ * with a red line overlay for failure counts on a secondary right axis.
20
+ */
21
+ private buildPhaseChart;
22
+ /**
23
+ * Registers Jest describe/it blocks for the scenario.
24
+ * Creates one `it` per phase — its never fail, errors are only recorded
25
+ * in aggregated results. Logs a per-phase console table and reports it
26
+ * via TestReporter after each `it`; reports combined table + bar chart
27
+ * in `afterAll`.
28
+ *
29
+ * @param hooks Optional lifecycle hooks:
30
+ * - `beforeAll`: runs after `scenario.initialize` but before any `it`.
31
+ * Use this to populate shared mutable state (e.g. metadata objects)
32
+ * that phase configs reference.
33
+ */
34
+ describeSuite(hooks?: {
35
+ beforeAll?: () => Promise<void> | void;
36
+ }): void;
37
+ }
@@ -0,0 +1,37 @@
1
+ import { PerformanceScenario, PerformanceRunner, PhaseResult } from "../utils/performanceRunner.js";
2
+ export type JestPerformanceScenario<TContext = Record<string, unknown>> = PerformanceScenario<TContext>;
3
+ export declare class JestPerformanceRunner<TContext = Record<string, unknown>> extends PerformanceRunner<TContext> {
4
+ protected scenario: JestPerformanceScenario<TContext>;
5
+ private readonly reporter;
6
+ constructor(scenario: JestPerformanceScenario<TContext>);
7
+ /** Disable the base-class text-table canvas; we render a proper bar chart instead. */
8
+ protected shouldRenderCanvas(): boolean;
9
+ /** Logs per-phase table to the jest-html-reporters attachment. */
10
+ private reportPhaseToReporter;
11
+ /**
12
+ * After all phases finish: console-log the combined summary (base class),
13
+ * then report the summary table and a bar chart with the reporter.
14
+ */
15
+ protected logSummary(results: PhaseResult<TContext>[]): Promise<void>;
16
+ private buildTableDef;
17
+ /**
18
+ * Builds a Chart.js config: grouped bar columns (Wall/Avg/Min/Max ms)
19
+ * with a red line overlay for failure counts on a secondary right axis.
20
+ */
21
+ private buildPhaseChart;
22
+ /**
23
+ * Registers Jest describe/it blocks for the scenario.
24
+ * Creates one `it` per phase — its never fail, errors are only recorded
25
+ * in aggregated results. Logs a per-phase console table and reports it
26
+ * via TestReporter after each `it`; reports combined table + bar chart
27
+ * in `afterAll`.
28
+ *
29
+ * @param hooks Optional lifecycle hooks:
30
+ * - `beforeAll`: runs after `scenario.initialize` but before any `it`.
31
+ * Use this to populate shared mutable state (e.g. metadata objects)
32
+ * that phase configs reference.
33
+ */
34
+ describeSuite(hooks?: {
35
+ beforeAll?: () => Promise<void> | void;
36
+ }): void;
37
+ }
@@ -0,0 +1,5 @@
1
+ import { SpawnOptionsWithoutStdio } from "child_process";
2
+ import { OutputWriterConstructor, StandardOutputWriter } from "../writers.cjs";
3
+ import { CommandResult } from "../utils/types.cjs";
4
+ import { TestReporter } from "./TestReporter.cjs";
5
+ export declare function runAndReport<R = string>(command: string, opts: SpawnOptionsWithoutStdio | undefined, outputConstructor: OutputWriterConstructor<R, StandardOutputWriter<R>, Error> | undefined, reporter: TestReporter, commandPrefix?: string, ...args: unknown[]): CommandResult<R>;
@@ -0,0 +1,5 @@
1
+ import { SpawnOptionsWithoutStdio } from "child_process";
2
+ import { OutputWriterConstructor, StandardOutputWriter } from "../writers.js";
3
+ import { CommandResult } from "../utils/types.js";
4
+ import { TestReporter } from "./TestReporter.js";
5
+ export declare function runAndReport<R = string>(command: string, opts: SpawnOptionsWithoutStdio | undefined, outputConstructor: OutputWriterConstructor<R, StandardOutputWriter<R>, Error> | undefined, reporter: TestReporter, commandPrefix?: string, ...args: unknown[]): CommandResult<R>;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @description Default encoding for text operations.
3
+ * @summary The standard UTF-8 encoding used for text processing.
4
+ * @const {string} Encoding
5
+ * @memberOf module:utils
6
+ */
7
+ export declare const Encoding = "utf-8";
8
+ /**
9
+ * @description Regular expression for semantic versioning.
10
+ * @summary A regex pattern to match and parse semantic version strings.
11
+ * @const {RegExp} SemVersionRegex
12
+ * @memberOf module:utils
13
+ */
14
+ export declare const SemVersionRegex: RegExp;
15
+ /**
16
+ * @description Enum for semantic version components.
17
+ * @summary Defines the three levels of semantic versioning: PATCH, MINOR, and MAJOR.
18
+ * @enum {string}
19
+ * @memberOf module:utils
20
+ */
21
+ export declare enum SemVersion {
22
+ /** Patch version for backwards-compatible bug fixes. */
23
+ PATCH = "patch",
24
+ /** Minor version for backwards-compatible new features. */
25
+ MINOR = "minor",
26
+ /** Major version for changes that break backwards compatibility. */
27
+ MAJOR = "major"
28
+ }
29
+ /**
30
+ * @description Flag to indicate non-CI environment.
31
+ * @summary Used to specify that a command should run outside of a Continuous Integration environment.
32
+ * @const {string} NoCIFLag
33
+ * @memberOf module:utils
34
+ */
35
+ export declare const NoCIFLag = "-no-ci";
36
+ /**
37
+ * @description Key for the setup script in package.json.
38
+ * @summary Identifies the script that runs after package installation.
39
+ * @const {string} SetupScriptKey
40
+ * @memberOf module:utils
41
+ */
42
+ export declare const SetupScriptKey = "postinstall";
43
+ /**
44
+ * @description Enum for various authentication tokens.
45
+ * @summary Defines the file names for storing different types of authentication tokens.
46
+ * @enum {string}
47
+ * @memberOf module:utils
48
+ */
49
+ export declare enum Tokens {
50
+ /** Git authentication token file name. */
51
+ GIT = ".token",
52
+ /** NPM authentication token file name. */
53
+ NPM = ".npmtoken",
54
+ /** Docker authentication token file name. */
55
+ DOCKER = ".dockertoken",
56
+ /** Confluence authentication token file name. */
57
+ CONFLUENCE = ".confluence-token"
58
+ }
59
+ /**
60
+ * @description Code used to indicate an operation was aborted.
61
+ * @summary Standard message used when a process is manually terminated.
62
+ * @const {string} AbortCode
63
+ * @memberOf module:utils
64
+ */
65
+ export declare const AbortCode = "Aborted";