@alwaysmeticulous/cli 2.17.0 → 2.18.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.
- package/dist/commands/replay/replay.command.d.ts +8 -2
- package/dist/commands/replay/replay.command.js +60 -83
- package/dist/commands/replay/utils/compute-and-save-diff.d.ts +15 -0
- package/dist/commands/replay/utils/compute-and-save-diff.js +46 -0
- package/dist/commands/run-all-tests/run-all-tests.command.js +13 -5
- package/dist/commands/screenshot-diff/screenshot-diff.command.d.ts +11 -11
- package/dist/commands/screenshot-diff/screenshot-diff.command.js +20 -17
- package/dist/config/config.types.d.ts +4 -0
- package/dist/deflake-tests/deflake-tests.handler.d.ts +2 -2
- package/dist/deflake-tests/deflake-tests.handler.js +8 -20
- package/dist/parallel-tests/messages.types.d.ts +2 -2
- package/dist/parallel-tests/parallel-tests.handler.d.ts +4 -10
- package/dist/parallel-tests/parallel-tests.handler.js +6 -20
- package/dist/parallel-tests/run-all-tests.d.ts +14 -5
- package/dist/parallel-tests/run-all-tests.js +57 -46
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/run-all-tests.utils.d.ts +4 -5
- package/dist/utils/run-all-tests.utils.js +4 -7
- package/package.json +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ReplayExecutionOptions } from "@alwaysmeticulous/common";
|
|
2
2
|
import { TestRunStatus } from "../api/test-run.api";
|
|
3
3
|
import { ScreenshotAssertionsEnabledOptions } from "../command-utils/common-types";
|
|
4
|
-
import { TestCaseResult } from "../config/config.types";
|
|
4
|
+
import { DetailedTestCaseResult, TestCaseResult } from "../config/config.types";
|
|
5
5
|
import { TestRunProgress } from "./run-all-tests.types";
|
|
6
6
|
export interface Options {
|
|
7
7
|
testsFile: string | null;
|
|
8
8
|
executionOptions: ReplayExecutionOptions;
|
|
9
9
|
screenshottingOptions: ScreenshotAssertionsEnabledOptions;
|
|
10
10
|
apiToken: string | null;
|
|
11
|
-
commitSha: string
|
|
11
|
+
commitSha: string;
|
|
12
12
|
/**
|
|
13
13
|
* The base commit to compare test results against for test cases that don't have a baseReplayId specified.
|
|
14
14
|
*/
|
|
@@ -22,8 +22,13 @@ export interface Options {
|
|
|
22
22
|
*/
|
|
23
23
|
parallelTasks: number | null;
|
|
24
24
|
deflake: boolean;
|
|
25
|
-
useCache: boolean;
|
|
26
25
|
githubSummary: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* If provided it will incorportate the cachedTestRunResults in any calls to store
|
|
28
|
+
* test run results in the BE, but won't include the cachedTestRunResults in the returned
|
|
29
|
+
* RunAllTestsResult.
|
|
30
|
+
*/
|
|
31
|
+
cachedTestRunResults?: TestCaseResult[];
|
|
27
32
|
onTestRunCreated?: (testRun: TestRun & {
|
|
28
33
|
status: "Running";
|
|
29
34
|
}) => void;
|
|
@@ -35,7 +40,7 @@ export interface RunAllTestsResult {
|
|
|
35
40
|
testRun: TestRun & {
|
|
36
41
|
status: "Success" | "Failure";
|
|
37
42
|
};
|
|
38
|
-
testCaseResults:
|
|
43
|
+
testCaseResults: DetailedTestCaseResult[];
|
|
39
44
|
}
|
|
40
45
|
export interface TestRun {
|
|
41
46
|
id: string;
|
|
@@ -43,4 +48,8 @@ export interface TestRun {
|
|
|
43
48
|
status: TestRunStatus;
|
|
44
49
|
progress: TestRunProgress;
|
|
45
50
|
}
|
|
46
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Runs all the test cases in the provided file.
|
|
53
|
+
* @returns The results of the tests that were executed (note that this does not include results from any cachedTestRunResults passed in)
|
|
54
|
+
*/
|
|
55
|
+
export declare const runAllTests: ({ testsFile, apiToken, commitSha, baseCommitSha, appUrl, useAssetsSnapshottedInBaseSimulation, executionOptions, screenshottingOptions, parallelTasks, deflake, cachedTestRunResults: cachedTestRunResults_, githubSummary, onTestRunCreated, onTestFinished: onTestFinished_, }: Options) => Promise<RunAllTestsResult>;
|
|
@@ -12,27 +12,31 @@ const config_1 = require("../config/config");
|
|
|
12
12
|
const deflake_tests_handler_1 = require("../deflake-tests/deflake-tests.handler");
|
|
13
13
|
const replay_assets_1 = require("../local-data/replay-assets");
|
|
14
14
|
const parallel_tests_handler_1 = require("../parallel-tests/parallel-tests.handler");
|
|
15
|
-
const commit_sha_utils_1 = require("../utils/commit-sha.utils");
|
|
16
15
|
const config_utils_1 = require("../utils/config.utils");
|
|
17
16
|
const github_summary_utils_1 = require("../utils/github-summary.utils");
|
|
18
17
|
const run_all_tests_utils_1 = require("../utils/run-all-tests.utils");
|
|
19
18
|
const version_utils_1 = require("../utils/version.utils");
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Runs all the test cases in the provided file.
|
|
21
|
+
* @returns The results of the tests that were executed (note that this does not include results from any cachedTestRunResults passed in)
|
|
22
|
+
*/
|
|
23
|
+
const runAllTests = async ({ testsFile, apiToken, commitSha, baseCommitSha, appUrl, useAssetsSnapshottedInBaseSimulation, executionOptions, screenshottingOptions, parallelTasks, deflake, cachedTestRunResults: cachedTestRunResults_, githubSummary, onTestRunCreated, onTestFinished: onTestFinished_, }) => {
|
|
21
24
|
if (appUrl != null && useAssetsSnapshottedInBaseSimulation) {
|
|
22
25
|
throw new Error("Arguments useAssetsSnapshottedInBaseSimulation and appUrl are mutually exclusive");
|
|
23
26
|
}
|
|
24
27
|
const logger = loglevel_1.default.getLogger(common_1.METICULOUS_LOGGER_NAME);
|
|
25
28
|
const client = (0, client_1.createClient)({ apiToken });
|
|
29
|
+
const cachedTestRunResults = cachedTestRunResults_ !== null && cachedTestRunResults_ !== void 0 ? cachedTestRunResults_ : [];
|
|
26
30
|
const config = await (0, config_1.readConfig)(testsFile || undefined);
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
31
|
+
const allTestCases = config.testCases || [];
|
|
32
|
+
if (!allTestCases.length) {
|
|
29
33
|
throw new Error("Error! No test case defined");
|
|
30
34
|
}
|
|
31
|
-
|
|
35
|
+
// Only run the uncached test cases
|
|
36
|
+
const testCases = allTestCases.filter(({ sessionId, baseReplayId, title }) => !cachedTestRunResults.find((cached) => cached.sessionId === sessionId &&
|
|
37
|
+
cached.baseReplayId === baseReplayId &&
|
|
38
|
+
cached.title === title));
|
|
32
39
|
const meticulousSha = await (0, version_utils_1.getMeticulousVersion)();
|
|
33
|
-
const cachedTestRunResults = useCache
|
|
34
|
-
? await (0, test_run_api_1.getCachedTestRunResults)({ client, commitSha })
|
|
35
|
-
: [];
|
|
36
40
|
const replayEventsDependencies = await (0, replay_assets_1.loadReplayEventsDependencies)();
|
|
37
41
|
const testRun = await (0, test_run_api_1.createTestRun)({
|
|
38
42
|
client,
|
|
@@ -47,19 +51,57 @@ const runAllTests = async ({ testsFile, apiToken, commitSha: commitSha_, baseCom
|
|
|
47
51
|
status: "Running",
|
|
48
52
|
progress: {
|
|
49
53
|
failedTestCases: 0,
|
|
50
|
-
passedTestCases:
|
|
54
|
+
passedTestCases: cachedTestRunResults.length,
|
|
51
55
|
runningTestCases: testCases.length,
|
|
52
56
|
},
|
|
53
57
|
});
|
|
54
58
|
logger.info("");
|
|
55
59
|
logger.info(`Test run URL: ${testRunUrl}`);
|
|
56
60
|
logger.info("");
|
|
61
|
+
const testsToRun = await (0, run_all_tests_utils_1.getTestsToRun)({
|
|
62
|
+
testCases,
|
|
63
|
+
client,
|
|
64
|
+
baseCommitSha: baseCommitSha !== null && baseCommitSha !== void 0 ? baseCommitSha : null,
|
|
65
|
+
});
|
|
66
|
+
const storeTestRunResults = async (status, resultsSoFar) => {
|
|
67
|
+
const resultsToSendToBE = [
|
|
68
|
+
...cachedTestRunResults,
|
|
69
|
+
...resultsSoFar.map(
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
({ screenshotDiffResults, ...result }) => result),
|
|
72
|
+
];
|
|
73
|
+
try {
|
|
74
|
+
await (0, test_run_api_1.putTestRunResults)({
|
|
75
|
+
client,
|
|
76
|
+
testRunId: testRun.id,
|
|
77
|
+
status,
|
|
78
|
+
resultData: {
|
|
79
|
+
results: resultsToSendToBE,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
logger.error(`Error while pushing partial results: ${error}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const onTestFinished = async (progress, resultsSoFar) => {
|
|
88
|
+
onTestFinished_ === null || onTestFinished_ === void 0 ? void 0 : onTestFinished_({
|
|
89
|
+
id: testRun.id,
|
|
90
|
+
url: testRunUrl,
|
|
91
|
+
status: "Running",
|
|
92
|
+
progress: {
|
|
93
|
+
...progress,
|
|
94
|
+
passedTestCases: progress.passedTestCases + cachedTestRunResults.length,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
await storeTestRunResults("Running", resultsSoFar);
|
|
98
|
+
};
|
|
57
99
|
const getResults = async () => {
|
|
58
100
|
if (parallelTasks == null || parallelTasks > 1) {
|
|
59
101
|
const results = await (0, parallel_tests_handler_1.runAllTestsInParallel)({
|
|
60
102
|
config,
|
|
61
|
-
client,
|
|
62
103
|
testRun,
|
|
104
|
+
testsToRun,
|
|
63
105
|
executionOptions,
|
|
64
106
|
screenshottingOptions,
|
|
65
107
|
apiToken,
|
|
@@ -68,29 +110,14 @@ const runAllTests = async ({ testsFile, apiToken, commitSha: commitSha_, baseCom
|
|
|
68
110
|
useAssetsSnapshottedInBaseSimulation,
|
|
69
111
|
parallelTasks,
|
|
70
112
|
deflake,
|
|
71
|
-
cachedTestRunResults,
|
|
72
113
|
replayEventsDependencies,
|
|
73
|
-
|
|
74
|
-
onTestFinished: (progress) => {
|
|
75
|
-
onTestFinished === null || onTestFinished === void 0 ? void 0 : onTestFinished({
|
|
76
|
-
id: testRun.id,
|
|
77
|
-
url: testRunUrl,
|
|
78
|
-
status: "Running",
|
|
79
|
-
progress,
|
|
80
|
-
});
|
|
81
|
-
},
|
|
114
|
+
onTestFinished,
|
|
82
115
|
});
|
|
83
116
|
return results;
|
|
84
117
|
}
|
|
85
|
-
const results = [
|
|
86
|
-
const testsToRun = await (0, run_all_tests_utils_1.getTestsToRun)({
|
|
87
|
-
testCases,
|
|
88
|
-
cachedTestRunResults,
|
|
89
|
-
client,
|
|
90
|
-
baseCommitSha: baseCommitSha !== null && baseCommitSha !== void 0 ? baseCommitSha : null,
|
|
91
|
-
});
|
|
118
|
+
const results = [];
|
|
92
119
|
const progress = {
|
|
93
|
-
runningTestCases:
|
|
120
|
+
runningTestCases: testsToRun.length,
|
|
94
121
|
failedTestCases: 0,
|
|
95
122
|
passedTestCases: 0,
|
|
96
123
|
};
|
|
@@ -115,30 +142,14 @@ const runAllTests = async ({ testsFile, apiToken, commitSha: commitSha_, baseCom
|
|
|
115
142
|
progress.failedTestCases += result.result === "fail" ? 1 : 0;
|
|
116
143
|
progress.passedTestCases += result.result === "pass" ? 1 : 0;
|
|
117
144
|
--progress.runningTestCases;
|
|
118
|
-
|
|
119
|
-
id: testRun.id,
|
|
120
|
-
url: testRunUrl,
|
|
121
|
-
status: "Running",
|
|
122
|
-
progress,
|
|
123
|
-
});
|
|
124
|
-
await (0, test_run_api_1.putTestRunResults)({
|
|
125
|
-
client,
|
|
126
|
-
testRunId: testRun.id,
|
|
127
|
-
status: "Running",
|
|
128
|
-
resultData: { results },
|
|
129
|
-
});
|
|
145
|
+
await onTestFinished(progress, results);
|
|
130
146
|
}
|
|
131
147
|
return (0, run_all_tests_utils_1.sortResults)({ results, testCases });
|
|
132
148
|
};
|
|
133
149
|
const results = await getResults();
|
|
134
150
|
const runAllFailure = results.find(({ result }) => result === "fail");
|
|
135
151
|
const overallStatus = runAllFailure ? "Failure" : "Success";
|
|
136
|
-
await (
|
|
137
|
-
client,
|
|
138
|
-
testRunId: testRun.id,
|
|
139
|
-
status: overallStatus,
|
|
140
|
-
resultData: { results },
|
|
141
|
-
});
|
|
152
|
+
await storeTestRunResults(overallStatus, results);
|
|
142
153
|
logger.info("");
|
|
143
154
|
logger.info("Results");
|
|
144
155
|
logger.info("=======");
|