@alwaysmeticulous/cli 2.40.0 → 2.40.4

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 (121) hide show
  1. package/dist/api/test-run.api.d.ts +3 -31
  2. package/dist/api/test-run.api.js +3 -96
  3. package/dist/commands/download-replay/download-replay.command.js +4 -4
  4. package/dist/commands/download-session/download-session.command.js +4 -4
  5. package/dist/commands/record/record.command.js +8 -11
  6. package/dist/commands/replay/replay.command.d.ts +3 -14
  7. package/dist/commands/replay/replay.command.js +3 -233
  8. package/dist/commands/run-all-tests/run-all-tests.command.js +5 -5
  9. package/dist/commands/show-project/show-project.command.js +2 -3
  10. package/dist/index.d.ts +0 -7
  11. package/dist/index.js +1 -13
  12. package/dist/main.js +5 -11
  13. package/dist/utils/sentry.utils.d.ts +0 -4
  14. package/dist/utils/sentry.utils.js +3 -23
  15. package/package.json +14 -32
  16. package/dist/api/client.d.ts +0 -5
  17. package/dist/api/client.js +0 -32
  18. package/dist/api/download.d.ts +0 -1
  19. package/dist/api/download.js +0 -21
  20. package/dist/api/project.api.d.ts +0 -3
  21. package/dist/api/project.api.js +0 -22
  22. package/dist/api/replay-diff.api.d.ts +0 -13
  23. package/dist/api/replay-diff.api.js +0 -32
  24. package/dist/api/replay.api.d.ts +0 -36
  25. package/dist/api/replay.api.js +0 -89
  26. package/dist/api/session.api.d.ts +0 -6
  27. package/dist/api/session.api.js +0 -45
  28. package/dist/api/types.d.ts +0 -39
  29. package/dist/api/types.js +0 -2
  30. package/dist/api/upload.d.ts +0 -1
  31. package/dist/api/upload.js +0 -18
  32. package/dist/archive/archive.d.ts +0 -4
  33. package/dist/archive/archive.js +0 -64
  34. package/dist/command-utils/common-types.d.ts +0 -20
  35. package/dist/command-utils/common-types.js +0 -2
  36. package/dist/commands/bootstrap/bootstrap.command.d.ts +0 -2
  37. package/dist/commands/bootstrap/bootstrap.command.js +0 -33
  38. package/dist/commands/create-test/create-test.command.d.ts +0 -90
  39. package/dist/commands/create-test/create-test.command.js +0 -165
  40. package/dist/commands/replay/utils/compute-diff.d.ts +0 -13
  41. package/dist/commands/replay/utils/compute-diff.js +0 -95
  42. package/dist/commands/replay/utils/exit-early-if-skip-upload-env-var-set.d.ts +0 -1
  43. package/dist/commands/replay/utils/exit-early-if-skip-upload-env-var-set.js +0 -27
  44. package/dist/commands/screenshot-diff/screenshot-diff.command.d.ts +0 -53
  45. package/dist/commands/screenshot-diff/screenshot-diff.command.js +0 -182
  46. package/dist/commands/screenshot-diff/utils/__tests__/get-screenshot-identifier.spec.d.ts +0 -1
  47. package/dist/commands/screenshot-diff/utils/__tests__/get-screenshot-identifier.spec.js +0 -25
  48. package/dist/commands/screenshot-diff/utils/get-screenshot-filename.d.ts +0 -2
  49. package/dist/commands/screenshot-diff/utils/get-screenshot-filename.js +0 -22
  50. package/dist/commands/screenshot-diff/utils/get-screenshot-identifier.d.ts +0 -2
  51. package/dist/commands/screenshot-diff/utils/get-screenshot-identifier.js +0 -39
  52. package/dist/commands/screenshot-diff/utils/has-notable-differences.d.ts +0 -2
  53. package/dist/commands/screenshot-diff/utils/has-notable-differences.js +0 -10
  54. package/dist/commands/serve/serve.command.d.ts +0 -10
  55. package/dist/commands/serve/serve.command.js +0 -31
  56. package/dist/commands/update-tests/update-tests.command.d.ts +0 -21
  57. package/dist/commands/update-tests/update-tests.command.js +0 -96
  58. package/dist/config/config.d.ts +0 -3
  59. package/dist/config/config.js +0 -69
  60. package/dist/config/config.types.d.ts +0 -16
  61. package/dist/config/config.types.js +0 -2
  62. package/dist/config/snippets.d.ts +0 -1
  63. package/dist/config/snippets.js +0 -18
  64. package/dist/errors/config.d.ts +0 -3
  65. package/dist/errors/config.js +0 -10
  66. package/dist/image/diff.utils.d.ts +0 -19
  67. package/dist/image/diff.utils.js +0 -25
  68. package/dist/image/io.utils.d.ts +0 -3
  69. package/dist/image/io.utils.js +0 -25
  70. package/dist/local-data/local-data.utils.d.ts +0 -20
  71. package/dist/local-data/local-data.utils.js +0 -92
  72. package/dist/local-data/replay-assets.d.ts +0 -3
  73. package/dist/local-data/replay-assets.js +0 -94
  74. package/dist/local-data/replays.d.ts +0 -18
  75. package/dist/local-data/replays.js +0 -87
  76. package/dist/local-data/screenshot-diffs.d.ts +0 -7
  77. package/dist/local-data/screenshot-diffs.js +0 -20
  78. package/dist/local-data/serve-assets-from-simulation.d.ts +0 -5
  79. package/dist/local-data/serve-assets-from-simulation.js +0 -52
  80. package/dist/local-data/sessions.d.ts +0 -10
  81. package/dist/local-data/sessions.js +0 -41
  82. package/dist/parallel-tests/__tests__/merge-test-results.spec.d.ts +0 -1
  83. package/dist/parallel-tests/__tests__/merge-test-results.spec.js +0 -104
  84. package/dist/parallel-tests/__tests__/mock-test-results.d.ts +0 -17
  85. package/dist/parallel-tests/__tests__/mock-test-results.js +0 -106
  86. package/dist/parallel-tests/__tests__/parrallel-tests.handler.spec.d.ts +0 -1
  87. package/dist/parallel-tests/__tests__/parrallel-tests.handler.spec.js +0 -205
  88. package/dist/parallel-tests/execute-test-in-child-process.d.ts +0 -3
  89. package/dist/parallel-tests/execute-test-in-child-process.js +0 -44
  90. package/dist/parallel-tests/merge-test-results.d.ts +0 -12
  91. package/dist/parallel-tests/merge-test-results.js +0 -106
  92. package/dist/parallel-tests/messages.types.d.ts +0 -17
  93. package/dist/parallel-tests/messages.types.js +0 -2
  94. package/dist/parallel-tests/parallel-replay.handler.d.ts +0 -3
  95. package/dist/parallel-tests/parallel-replay.handler.js +0 -56
  96. package/dist/parallel-tests/parallel-replay.types.d.ts +0 -16
  97. package/dist/parallel-tests/parallel-replay.types.js +0 -2
  98. package/dist/parallel-tests/parallel-tests.handler.d.ts +0 -14
  99. package/dist/parallel-tests/parallel-tests.handler.js +0 -194
  100. package/dist/parallel-tests/run-all-tests.d.ts +0 -73
  101. package/dist/parallel-tests/run-all-tests.js +0 -237
  102. package/dist/parallel-tests/run-all-tests.types.d.ts +0 -6
  103. package/dist/parallel-tests/run-all-tests.types.js +0 -2
  104. package/dist/parallel-tests/screenshot-diff-results.utils.d.ts +0 -7
  105. package/dist/parallel-tests/screenshot-diff-results.utils.js +0 -20
  106. package/dist/parallel-tests/task.handler.d.ts +0 -1
  107. package/dist/parallel-tests/task.handler.js +0 -86
  108. package/dist/utils/api-token.utils.d.ts +0 -1
  109. package/dist/utils/api-token.utils.js +0 -31
  110. package/dist/utils/commit-sha.utils.d.ts +0 -1
  111. package/dist/utils/commit-sha.utils.js +0 -42
  112. package/dist/utils/config.utils.d.ts +0 -7
  113. package/dist/utils/config.utils.js +0 -33
  114. package/dist/utils/github-summary.utils.d.ts +0 -5
  115. package/dist/utils/github-summary.utils.js +0 -38
  116. package/dist/utils/run-all-tests.utils.d.ts +0 -16
  117. package/dist/utils/run-all-tests.utils.js +0 -32
  118. package/dist/utils/test-run-environment.utils.d.ts +0 -2
  119. package/dist/utils/test-run-environment.utils.js +0 -25
  120. package/dist/utils/version.utils.d.ts +0 -1
  121. package/dist/utils/version.utils.js +0 -17
@@ -1,205 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const common_1 = require("@alwaysmeticulous/common");
4
- const parallel_tests_handler_1 = require("../parallel-tests.handler");
5
- const mock_test_results_1 = require("./mock-test-results");
6
- describe("runAllTestsInParallel", () => {
7
- it("maximises the number of tests run in parralel, up to the provided limit", async () => {
8
- let progress = {
9
- runningTestCases: 4,
10
- failedTestCases: 0,
11
- flakedTestCases: 0,
12
- passedTestCases: 0,
13
- };
14
- let testsStarted = 0;
15
- const testRunPromises = [(0, common_1.defer)(), (0, common_1.defer)(), (0, common_1.defer)(), (0, common_1.defer)()];
16
- const overallPromise = (0, parallel_tests_handler_1.runAllTestsInParallel)({
17
- testsToRun: [testCase(0), testCase(1), testCase(2), testCase(3)],
18
- parallelTasks: 2,
19
- maxRetriesOnFailure: 0,
20
- rerunTestsNTimes: 0,
21
- executeTest: async (testCase) => {
22
- var _a;
23
- testsStarted++;
24
- await testRunPromises[parseInt((_a = testCase.title) !== null && _a !== void 0 ? _a : "")].promise;
25
- return (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0)], testCase);
26
- },
27
- onTestFinished: async (newProgress) => {
28
- progress = newProgress;
29
- },
30
- });
31
- await waitForPromisesToFlush();
32
- expect(testsStarted).toEqual(2);
33
- expect(progress).toEqual({
34
- runningTestCases: 4,
35
- failedTestCases: 0,
36
- flakedTestCases: 0,
37
- passedTestCases: 0,
38
- });
39
- testRunPromises[0].resolve();
40
- await waitForPromisesToFlush();
41
- expect(testsStarted).toEqual(3);
42
- expect(progress).toEqual({
43
- runningTestCases: 3,
44
- failedTestCases: 0,
45
- flakedTestCases: 0,
46
- passedTestCases: 1,
47
- });
48
- testRunPromises[1].resolve();
49
- testRunPromises[2].resolve();
50
- await waitForPromisesToFlush();
51
- expect(testsStarted).toEqual(4);
52
- expect(progress).toEqual({
53
- runningTestCases: 1,
54
- failedTestCases: 0,
55
- flakedTestCases: 0,
56
- passedTestCases: 3,
57
- });
58
- await expectPromiseToNotHaveResolved(overallPromise);
59
- testRunPromises[3].resolve();
60
- await waitForPromisesToFlush();
61
- expect(progress).toEqual({
62
- runningTestCases: 0,
63
- failedTestCases: 0,
64
- flakedTestCases: 0,
65
- passedTestCases: 4,
66
- });
67
- await overallPromise;
68
- });
69
- it("can handle a test failing to run", async () => {
70
- let progress = {
71
- runningTestCases: 4,
72
- failedTestCases: 0,
73
- flakedTestCases: 0,
74
- passedTestCases: 0,
75
- };
76
- const testRunPromises = [(0, common_1.defer)(), (0, common_1.defer)(), (0, common_1.defer)(), (0, common_1.defer)()];
77
- const overallPromise = (0, parallel_tests_handler_1.runAllTestsInParallel)({
78
- testsToRun: [testCase(0), testCase(1), testCase(2), testCase(3)],
79
- parallelTasks: 2,
80
- maxRetriesOnFailure: 0,
81
- rerunTestsNTimes: 0,
82
- executeTest: async (testCase) => {
83
- var _a;
84
- await testRunPromises[parseInt((_a = testCase.title) !== null && _a !== void 0 ? _a : "")].promise;
85
- return (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0)], testCase);
86
- },
87
- onTestFinished: async (newProgress) => {
88
- progress = newProgress;
89
- },
90
- });
91
- testRunPromises[0].resolve();
92
- testRunPromises[1].reject();
93
- testRunPromises[2].resolve();
94
- testRunPromises[3].resolve();
95
- const result = await overallPromise;
96
- expect(progress).toEqual({
97
- runningTestCases: 0,
98
- failedTestCases: 1,
99
- flakedTestCases: 0,
100
- passedTestCases: 3,
101
- });
102
- // No result given for test 1 (it can't, because it doesn't have a headReplayId)
103
- expect(result).toEqual([
104
- (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0)], testCase(0)),
105
- (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0)], testCase(2)),
106
- (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0)], testCase(3)),
107
- ]);
108
- });
109
- it("does not retry failed tests if maxRetriesOnFailure is 0", async () => {
110
- const results = await (0, parallel_tests_handler_1.runAllTestsInParallel)({
111
- testsToRun: [testCase(0)],
112
- parallelTasks: 2,
113
- maxRetriesOnFailure: 0,
114
- rerunTestsNTimes: 0,
115
- executeTest: async (testCase) => {
116
- return (0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.diff)(0)], testCase);
117
- },
118
- });
119
- expect(results).toEqual([(0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.diff)(0)], testCase(0))]);
120
- });
121
- it("retries failed tests until maxRetriesOnFailure reached or first flake seen for all screenshots if maxRetriesOnFailure > 0", async () => {
122
- let retryNum = 0;
123
- const results = await (0, parallel_tests_handler_1.runAllTestsInParallel)({
124
- testsToRun: [testCase(0)],
125
- parallelTasks: 2,
126
- maxRetriesOnFailure: 10,
127
- rerunTestsNTimes: 0,
128
- executeTest: async (testCase, isRetry) => {
129
- if (!isRetry) {
130
- return (0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.diff)(0), (0, mock_test_results_1.diff)(1)], testCase);
131
- }
132
- if (retryNum === 3) {
133
- return (0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.missingHead)(0), (0, mock_test_results_1.diff)(1)], testCase);
134
- }
135
- retryNum++;
136
- return (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0), (0, mock_test_results_1.diff)(1)], testCase);
137
- },
138
- });
139
- expect(retryNum).toEqual(3);
140
- expect(results).toEqual([
141
- (0, mock_test_results_1.testResult)("flake", [
142
- (0, mock_test_results_1.flake)(0, (0, mock_test_results_1.diff)(), [(0, mock_test_results_1.missingHead)()]),
143
- (0, mock_test_results_1.flake)(1, (0, mock_test_results_1.diff)(), [(0, mock_test_results_1.diff)(), (0, mock_test_results_1.diff)(), (0, mock_test_results_1.diff)(), (0, mock_test_results_1.diff)()]),
144
- ], testCase(0)),
145
- ]);
146
- });
147
- it("marks test as a failure if hit max number of retries and no flakes detected", async () => {
148
- const results = await (0, parallel_tests_handler_1.runAllTestsInParallel)({
149
- testsToRun: [testCase(0)],
150
- parallelTasks: 2,
151
- maxRetriesOnFailure: 3,
152
- rerunTestsNTimes: 0,
153
- executeTest: async (testCase, isRetry) => {
154
- if (!isRetry) {
155
- return (0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.diff)(0), (0, mock_test_results_1.diff)(1)], testCase);
156
- }
157
- return (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0), (0, mock_test_results_1.diff)(1)], testCase);
158
- },
159
- });
160
- expect(results).toEqual([
161
- (0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.diff)(0), (0, mock_test_results_1.flake)(1, (0, mock_test_results_1.diff)(), [(0, mock_test_results_1.diff)(), (0, mock_test_results_1.diff)(), (0, mock_test_results_1.diff)()])], testCase(0)),
162
- ]);
163
- });
164
- it("retries N times if rerunTestsNTimes > 0", async () => {
165
- let rerunNum = 0;
166
- const results = await (0, parallel_tests_handler_1.runAllTestsInParallel)({
167
- testsToRun: [testCase(0)],
168
- parallelTasks: 2,
169
- maxRetriesOnFailure: 0,
170
- rerunTestsNTimes: 3,
171
- executeTest: async (testCase, isRetry) => {
172
- if (!isRetry) {
173
- return (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.diff)(0), (0, mock_test_results_1.noDiff)(1)], testCase);
174
- }
175
- if (rerunNum === 2) {
176
- return (0, mock_test_results_1.testResult)("fail", [(0, mock_test_results_1.missingHead)(0), (0, mock_test_results_1.diff)(1)], testCase);
177
- }
178
- rerunNum++;
179
- return (0, mock_test_results_1.testResult)("pass", [(0, mock_test_results_1.noDiff)(0), (0, mock_test_results_1.noDiff)(1)], testCase);
180
- },
181
- });
182
- expect(rerunNum).toEqual(2);
183
- expect(results).toEqual([
184
- (0, mock_test_results_1.testResult)(
185
- // Flake outcome is returned iff all screenshots are flaky.
186
- "flake", [(0, mock_test_results_1.flake)(0, (0, mock_test_results_1.diff)(), [(0, mock_test_results_1.missingHead)()]), (0, mock_test_results_1.flake)(1, (0, mock_test_results_1.noDiff)(), [(0, mock_test_results_1.diff)()])], testCase(0)),
187
- ]);
188
- });
189
- });
190
- const testCase = (num) => ({
191
- sessionId: "mock-session-id",
192
- title: `${num}`,
193
- baseTestRunId: "mock-base-test-run-id",
194
- });
195
- const expectPromiseToNotHaveResolved = async (promise) => {
196
- let resolved = false;
197
- promise.then(() => {
198
- resolved = true;
199
- }, () => {
200
- resolved = true;
201
- });
202
- await waitForPromisesToFlush();
203
- expect(resolved).toEqual(false);
204
- };
205
- const waitForPromisesToFlush = () => new Promise((resolve) => setTimeout(resolve, 0));
@@ -1,3 +0,0 @@
1
- import { DetailedTestCaseResult } from "../config/config.types";
2
- import { InitMessage } from "./messages.types";
3
- export declare const executeTestInChildProcess: (initMessage: InitMessage) => Promise<DetailedTestCaseResult>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.executeTestInChildProcess = void 0;
7
- const child_process_1 = require("child_process");
8
- const path_1 = require("path");
9
- const common_1 = require("@alwaysmeticulous/common");
10
- const loglevel_1 = __importDefault(require("loglevel"));
11
- const executeTestInChildProcess = (initMessage) => {
12
- const logger = loglevel_1.default.getLogger(common_1.METICULOUS_LOGGER_NAME);
13
- const isTypeScript = __filename.endsWith(".ts");
14
- const taskHandler = (0, path_1.join)(__dirname, `task.handler${isTypeScript ? ".ts" : ".js"}`);
15
- const deferredResult = (0, common_1.defer)();
16
- const child = (0, child_process_1.fork)(taskHandler, [], { stdio: "inherit" });
17
- const messageHandler = (message) => {
18
- if (message &&
19
- typeof message === "object" &&
20
- message["kind"] === "result") {
21
- const resultMessage = message;
22
- deferredResult.resolve(resultMessage.data.result);
23
- child.off("message", messageHandler);
24
- }
25
- };
26
- child.on("error", (error) => {
27
- if (deferredResult.getState() === "pending") {
28
- deferredResult.reject(error);
29
- }
30
- });
31
- child.on("exit", (code) => {
32
- if (code) {
33
- logger.debug(`child exited with code: ${code}`);
34
- }
35
- if (deferredResult.getState() === "pending") {
36
- deferredResult.reject(new Error("No result"));
37
- }
38
- });
39
- child.on("message", messageHandler);
40
- // Send test case and arguments to child process
41
- child.send(initMessage);
42
- return deferredResult.promise;
43
- };
44
- exports.executeTestInChildProcess = executeTestInChildProcess;
@@ -1,12 +0,0 @@
1
- import { ScreenshotDiffResult } from "@alwaysmeticulous/api";
2
- import { DetailedTestCaseResult, TestCaseResult } from "../config/config.types";
3
- export interface ResultsToMerge {
4
- currentResult: DetailedTestCaseResult;
5
- /**
6
- * The result of replaying the session once more against the head commit and
7
- * comparing the screenshots to those taken on the first replay against the head commit.
8
- */
9
- comparisonToHeadReplay: DetailedTestCaseResult;
10
- }
11
- export declare const mergeResults: ({ currentResult, comparisonToHeadReplay, }: ResultsToMerge) => DetailedTestCaseResult;
12
- export declare const testRunOutcomeFromDiffResults: (currentResult: TestCaseResult["result"], newScreenshotDiffResults: ScreenshotDiffResult[]) => TestCaseResult["result"];
@@ -1,106 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.testRunOutcomeFromDiffResults = exports.mergeResults = void 0;
7
- const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
8
- const has_notable_differences_1 = require("../commands/screenshot-diff/utils/has-notable-differences");
9
- const screenshot_diff_results_utils_1 = require("./screenshot-diff-results.utils");
10
- const mergeResults = ({ currentResult, comparisonToHeadReplay, }) => {
11
- // If any of the screenshots diffs in comparisonToHeadReplay show a diff against one
12
- // of the screenshots that orignally failed in currentResult then we have a flake
13
- // on our hands
14
- const retryDiffById = new Map();
15
- (0, screenshot_diff_results_utils_1.flattenScreenshotDiffResults)(comparisonToHeadReplay).forEach((result) => {
16
- const hash = hashScreenshotIdentifier(result.identifier);
17
- if (retryDiffById.has(hash)) {
18
- throw new Error(`Received two screenshots for the same identifier '${hash}'. Screenshots should be unique.`);
19
- }
20
- retryDiffById.set(hash, result);
21
- });
22
- const newScreenshotDiffResults = (0, screenshot_diff_results_utils_1.flattenScreenshotDiffResults)(currentResult).map((currentDiff) => {
23
- const hash = hashScreenshotIdentifier(currentDiff.identifier);
24
- const diffWhenRetrying = retryDiffById.get(hash);
25
- // diffWhenRetrying is null in the case that there is a base screenshot for the base replay,
26
- // but the first replay on head did not generate a head screenshot (got 'missing-head'),
27
- // and the replay of that did not generate a head screenshot either (if the first replay on head
28
- // did generate a screenshot, then diffWhenRetrying.outcome would be 'missing-head' instead)
29
- if (diffWhenRetrying == null) {
30
- const diffToBaseScreenshotOutcome = currentDiff.outcome === "flake"
31
- ? currentDiff.diffToBaseScreenshot.outcome
32
- : currentDiff.outcome;
33
- if (diffToBaseScreenshotOutcome !== "missing-head") {
34
- throw new Error(`Expected to find a screenshot comparison for ${hash}, but none was found. The screenshot must
35
- have existed in the orginal replay, since the orginal comparison outcome was not '${diffToBaseScreenshotOutcome}'.`);
36
- }
37
- if (currentDiff.outcome === "flake") {
38
- // Original comparison had missing-head, so we re-ran to check if it was flakey. In this case
39
- // we got the same result.
40
- return {
41
- ...currentDiff,
42
- diffsToHeadScreenshotOnRetries: [
43
- ...currentDiff.diffsToHeadScreenshotOnRetries,
44
- { outcome: "missing-base-and-head" },
45
- ],
46
- };
47
- }
48
- return currentDiff; // no difference, both screenshots were missing
49
- }
50
- if (diffWhenRetrying.outcome === "flake") {
51
- throw new Error("Expected diffs when retrying and comparing to the original head screenshot to be first-try diffs, but got a flake.");
52
- }
53
- if (currentDiff.outcome === "flake") {
54
- return {
55
- ...currentDiff,
56
- diffsToHeadScreenshotOnRetries: [
57
- ...currentDiff.diffsToHeadScreenshotOnRetries,
58
- withoutIdentifiers(diffWhenRetrying),
59
- ],
60
- };
61
- }
62
- else if ((diffWhenRetrying === null || diffWhenRetrying === void 0 ? void 0 : diffWhenRetrying.outcome) === "no-diff") {
63
- return currentDiff;
64
- }
65
- else {
66
- return {
67
- baseReplayId: currentDiff.baseReplayId,
68
- identifier: currentDiff.identifier,
69
- outcome: "flake",
70
- diffToBaseScreenshot: withoutIdentifiers(currentDiff),
71
- diffsToHeadScreenshotOnRetries: [withoutIdentifiers(diffWhenRetrying)],
72
- };
73
- }
74
- });
75
- return {
76
- ...currentResult,
77
- result: (0, exports.testRunOutcomeFromDiffResults)(currentResult.result, newScreenshotDiffResults),
78
- screenshotDiffResultsByBaseReplayId: (0, screenshot_diff_results_utils_1.groupScreenshotDiffResults)(newScreenshotDiffResults),
79
- };
80
- };
81
- exports.mergeResults = mergeResults;
82
- const withoutIdentifiers = ({
83
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
84
- identifier: _identifier,
85
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
86
- baseReplayId: _baseReplayId, ...rest }) => rest;
87
- const hashScreenshotIdentifier = (identifier) => {
88
- return (0, fast_json_stable_stringify_1.default)(identifier);
89
- };
90
- const testRunOutcomeFromDiffResults = (currentResult, newScreenshotDiffResults) => {
91
- // If a test run is already flakey, we don't want to overwrite that with a 'fail' result.
92
- if (currentResult === "flake") {
93
- return "flake";
94
- }
95
- const hasOnlyFlakes = newScreenshotDiffResults.every(({ outcome }) => outcome === "flake" || outcome === "no-diff");
96
- if (hasOnlyFlakes) {
97
- return "flake";
98
- }
99
- // If we've had a test run has already failed, we don't want to overwrite that with a 'pass' result.
100
- // Otherwise, if there are any notable differences, we want to fail the test run.
101
- return currentResult === "fail" ||
102
- (0, has_notable_differences_1.hasNotableDifferences)(newScreenshotDiffResults)
103
- ? "fail"
104
- : "pass";
105
- };
106
- exports.testRunOutcomeFromDiffResults = testRunOutcomeFromDiffResults;
@@ -1,17 +0,0 @@
1
- import log from "loglevel";
2
- import { DetailedTestCaseResult } from "../config/config.types";
3
- import { ParallelTestsReplayOptions } from "./parallel-replay.types";
4
- export interface InitMessage {
5
- kind: "init";
6
- data: {
7
- logLevel: log.LogLevel[keyof log.LogLevel];
8
- dataDir: string;
9
- replayOptions: ParallelTestsReplayOptions;
10
- };
11
- }
12
- export interface ResultMessage {
13
- kind: "result";
14
- data: {
15
- result: DetailedTestCaseResult;
16
- };
17
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { DetailedTestCaseResult } from "../config/config.types";
2
- import { ParallelTestsReplayOptions } from "./parallel-replay.types";
3
- export declare const handleReplay: ({ testCase, replayTarget, executionOptions, screenshottingOptions, apiToken, commitSha, generatedBy, testRunId, replayEventsDependencies, suppressScreenshotDiffLogging, baseTestRunId, }: ParallelTestsReplayOptions) => Promise<DetailedTestCaseResult>;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleReplay = void 0;
4
- const replay_command_1 = require("../commands/replay/replay.command");
5
- const has_notable_differences_1 = require("../commands/screenshot-diff/utils/has-notable-differences");
6
- const handleReplay = async ({ testCase, replayTarget, executionOptions, screenshottingOptions, apiToken, commitSha, generatedBy, testRunId, replayEventsDependencies, suppressScreenshotDiffLogging, baseTestRunId, }) => {
7
- var _a, _b;
8
- const { replay, screenshotDiffResultsByBaseReplayId } = await (0, replay_command_1.replayCommandHandler)({
9
- replayTarget,
10
- executionOptions: applyTestCaseExecutionOptionOverrides(executionOptions, (_a = testCase.options) !== null && _a !== void 0 ? _a : {}),
11
- screenshottingOptions: applyTestCaseScreenshottingOptionsOverrides(screenshottingOptions, (_b = testCase.options) !== null && _b !== void 0 ? _b : {}),
12
- apiToken,
13
- commitSha,
14
- sessionId: testCase.sessionId,
15
- baseTestRunId,
16
- cookiesFile: null,
17
- generatedBy,
18
- testRunId,
19
- replayEventsDependencies,
20
- suppressScreenshotDiffLogging,
21
- debugger: false,
22
- });
23
- const result = (0, has_notable_differences_1.hasNotableDifferences)(Object.values(screenshotDiffResultsByBaseReplayId).flat())
24
- ? "fail"
25
- : "pass";
26
- return {
27
- ...testCase,
28
- headReplayId: replay.id,
29
- result,
30
- screenshotDiffResultsByBaseReplayId,
31
- };
32
- };
33
- exports.handleReplay = handleReplay;
34
- const applyTestCaseExecutionOptionOverrides = (executionOptionsFromCliFlags, overridesFromTestCase) => {
35
- var _a;
36
- // Options specified in the test case override those passed as CLI flags
37
- // (CLI flags set the defaults)
38
- return {
39
- ...executionOptionsFromCliFlags,
40
- moveBeforeClick: (_a = overridesFromTestCase.moveBeforeClick) !== null && _a !== void 0 ? _a : executionOptionsFromCliFlags.moveBeforeClick,
41
- };
42
- };
43
- const applyTestCaseScreenshottingOptionsOverrides = (screenshottingOptionsFromCliFlags, overridesFromTestCase) => {
44
- var _a, _b;
45
- // Options specified in the test case override those passed as CLI flags
46
- // (CLI flags set the defaults)
47
- const diffOptions = {
48
- diffThreshold: (_a = overridesFromTestCase.diffThreshold) !== null && _a !== void 0 ? _a : screenshottingOptionsFromCliFlags.diffOptions.diffThreshold,
49
- diffPixelThreshold: (_b = overridesFromTestCase.diffPixelThreshold) !== null && _b !== void 0 ? _b : screenshottingOptionsFromCliFlags.diffOptions.diffPixelThreshold,
50
- };
51
- return {
52
- enabled: true,
53
- diffOptions,
54
- storyboardOptions: screenshottingOptionsFromCliFlags.storyboardOptions,
55
- };
56
- };
@@ -1,16 +0,0 @@
1
- import { TestCase } from "@alwaysmeticulous/api";
2
- import { GeneratedBy, ReplayEventsDependencies, ReplayExecutionOptions, ReplayTarget } from "@alwaysmeticulous/common";
3
- import { ScreenshotAssertionsEnabledOptions } from "../command-utils/common-types";
4
- export interface ParallelTestsReplayOptions {
5
- replayTarget: ReplayTarget;
6
- executionOptions: ReplayExecutionOptions;
7
- screenshottingOptions: ScreenshotAssertionsEnabledOptions;
8
- testCase: TestCase;
9
- apiToken: string | null;
10
- commitSha: string;
11
- generatedBy: GeneratedBy;
12
- testRunId: string | null;
13
- baseTestRunId: string | null;
14
- replayEventsDependencies: ReplayEventsDependencies;
15
- suppressScreenshotDiffLogging: boolean;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +0,0 @@
1
- import { TestCase } from "@alwaysmeticulous/api";
2
- import { DetailedTestCaseResult } from "../config/config.types";
3
- import { TestRunProgress } from "./run-all-tests.types";
4
- export interface RunAllTestsInParallelOptions {
5
- testsToRun: TestCase[];
6
- parallelTasks: number | null;
7
- maxRetriesOnFailure: number;
8
- rerunTestsNTimes: number;
9
- executeTest: (testCase: TestCase, isRetry: boolean) => Promise<DetailedTestCaseResult>;
10
- onTestFinished?: (progress: TestRunProgress, resultsSoFar: DetailedTestCaseResult[]) => Promise<void>;
11
- onTestFailedToRun?: (progress: TestRunProgress) => Promise<void>;
12
- }
13
- /** Handler for running Meticulous tests in parallel using child processes */
14
- export declare const runAllTestsInParallel: (options: RunAllTestsInParallelOptions) => Promise<DetailedTestCaseResult[]>;