@mablhq/mabl-cli 2.55.0 → 2.57.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/browserLauncher/index.js +1 -1
- package/commands/constants.js +6 -5
- package/commands/tests/tests_cmds/run-mobile.js +2 -2
- package/commands/tests/tests_cmds/run.js +4 -3
- package/commands/tests/tests_cmds/runUtils.js +2 -2
- package/core/execution/ApiTestUtils.js +29 -18
- package/execution/index.js +2 -2
- package/execution/index.js.LICENSE.txt +0 -15
- package/package.json +4 -3
- package/reporters/reporter.js +77 -2
- package/upload/index.js +1 -1
- package/upload/index.js.LICENSE.txt +0 -15
package/commands/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandArgMablBranchChangesOnly = exports.CommandArgMablBranch = exports.CommandArgMablAutoLogin = exports.CommandArgMablAutoBranch = exports.CommandArgLinkBypass = exports.CommandArgLinkLabel = exports.CommandArgLimitOutput = exports.CommandArgLabels = exports.CommandArgLabelsInclude = exports.CommandArgLabelsExclude = exports.CommandArgTestInteractionSpeed = exports.CommandArgTestRunId = exports.CommandArgTestFile = exports.CommandArgKeepBrowserOpen = exports.CommandArgInput = exports.CommandArgIncludedTests = exports.CommandArgIncludeDefaults = exports.CommandArgId = exports.CommandArgUserAgent = exports.CommandArgHttpHeaders = exports.CommandArgHelp = exports.CommandArgHeadless = exports.CommandArgFromPlanId = exports.CommandArgFrom = exports.CommandArgFormat = exports.CommandArgFindPath = exports.CommandArgFastFailure = exports.CommandArgOverrideEnvironmentId = exports.CommandArgGrep = exports.CommandArgExtraArguments = exports.CommandArgExistingReport = exports.CommandArgExcludedTests = exports.CommandArgEnvironmentId = exports.CommandArgDetailLevel = exports.CommandArgDestination = exports.CommandArgDescription = exports.CommandArgDeploymentId = exports.CommandArgDecrypt = exports.CommandArgDebug = exports.CommandArgDataTables = exports.CommandArgDataTableId = exports.CommandArgCredentials = exports.CommandArgBasicAuthCredentials = exports.CommandArgBrowsers = exports.CommandArgBrowser = exports.CommandArgBranch = exports.CommandArgAuto = exports.CommandArgApplicationId = exports.CommandArgApiKey = exports.CommandArgABConfigFile = void 0;
|
|
4
|
-
exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.
|
|
4
|
+
exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.Reporter = exports.OutputFormats = exports.CommandArgAliases = exports.CommandArgBrowserEnableExtensions = exports.CommandArgBrowserIgnoreCertificateErrors = exports.CommandArgBrowserDisableIsolation = exports.ListTimeFormat = exports.CommandArgTimezoneID = exports.CommandArgLocale = exports.CommandArgUseTestExecutionProxy = exports.CommandArgScenarioId = exports.CommandArgReporterOptions = exports.CommandArgReporter = exports.CommandArgWorkspaceId = exports.CommandArgVersion = exports.CommandArgVariables = exports.CommandArgUrlApi = exports.CommandArgUrlApp = exports.CommandArgUrl = exports.CommandArgTo = exports.CommandArgTrainerVersion = exports.CommandArgTraceFile = exports.CommandArgTracesPath = exports.CommandArgTestPath = exports.CommandArgSilent = exports.CommandArgRevision = exports.CommandArgRecordVideoPath = exports.CommandArgMaxHeartbeatAge = exports.CommandArgPlanId = exports.CommandArgContentTypes = exports.CommandArgPreview = exports.CommandArgPath = exports.CommandArgOutputFilePath = exports.CommandArgOutput = exports.CommandArgNoPrompt = exports.CommandArgPrompt = exports.CommandArgProject = exports.CommandArgPortNumber = exports.CommandArgName = exports.CommandArgMobileDeviceName = exports.CommandArgMobilePlatform = exports.CommandArgMobileBuildFileId = exports.CommandArgMobileBuildFilePath = exports.CommandArgiOSdMobileAppFileId = exports.CommandArgAndroidMobileAppFileId = exports.CommandArgMulti = void 0;
|
|
5
5
|
exports.SCENARIO_ID_HEADER = exports.SCENARIO_NAME_HEADER = exports.ValidBrowserTypesForLocalRuns = exports.BrowserTypeSelections = void 0;
|
|
6
6
|
const browserTypes_1 = require("./browserTypes");
|
|
7
7
|
exports.CommandArgABConfigFile = 'ab-config-file';
|
|
@@ -130,10 +130,11 @@ var OutputFormats;
|
|
|
130
130
|
OutputFormats["Table"] = "table";
|
|
131
131
|
OutputFormats["Yaml"] = "yaml";
|
|
132
132
|
})(OutputFormats || (exports.OutputFormats = OutputFormats = {}));
|
|
133
|
-
var
|
|
134
|
-
(function (
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
var Reporter;
|
|
134
|
+
(function (Reporter) {
|
|
135
|
+
Reporter["Mabl"] = "mabl";
|
|
136
|
+
Reporter["Mochawesome"] = "mochawesome";
|
|
137
|
+
})(Reporter || (exports.Reporter = Reporter = {}));
|
|
137
138
|
var DetailLevelFormats;
|
|
138
139
|
(function (DetailLevelFormats) {
|
|
139
140
|
DetailLevelFormats["Full"] = "full";
|
|
@@ -72,7 +72,7 @@ exports.builder = (yargs) => {
|
|
|
72
72
|
describe: 'Output test run information for specified reporter',
|
|
73
73
|
hidden: true,
|
|
74
74
|
type: 'string',
|
|
75
|
-
choices: [constants_1.
|
|
75
|
+
choices: [constants_1.Reporter.Mochawesome],
|
|
76
76
|
})
|
|
77
77
|
.option(constants_1.CommandArgTestRunId, {
|
|
78
78
|
describe: 'The id of the test run to pull config from',
|
|
@@ -183,7 +183,7 @@ async function run(parsed) {
|
|
|
183
183
|
(0, testsUtil_1.cleanupTestResources)(testContext);
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
await (0, runUtils_1.logTestResults)(results, parsed, commandStartTime, generateRunCommandTemplate(parsed, results));
|
|
186
|
+
await (0, runUtils_1.logTestResults)(results, parsed, commandStartTime, generateRunCommandTemplate(parsed, results), mablTestsRunner.apiClient);
|
|
187
187
|
if (!results.success && !testRunnerConfig.keepBrowserOpen) {
|
|
188
188
|
process.exit(1);
|
|
189
189
|
}
|
|
@@ -135,10 +135,10 @@ Note: Setting the environment does not override the default URL. Please use the
|
|
|
135
135
|
type: 'boolean',
|
|
136
136
|
})
|
|
137
137
|
.option(constants_1.CommandArgReporter, {
|
|
138
|
-
describe: 'Output test run information for specified reporter',
|
|
138
|
+
describe: 'Output test run information for specified reporter. (mabl reporter requires the mabl_local_reporter feature flag)',
|
|
139
139
|
hidden: true,
|
|
140
140
|
type: 'string',
|
|
141
|
-
choices: [constants_1.
|
|
141
|
+
choices: [constants_1.Reporter.Mochawesome, constants_1.Reporter.Mabl],
|
|
142
142
|
})
|
|
143
143
|
.option(constants_1.CommandArgReporterOptions, {
|
|
144
144
|
describe: 'Reporter options as comma separated key/values pairs. e.g. "reportDir=path/to,json=true"',
|
|
@@ -284,7 +284,8 @@ async function run(parsed) {
|
|
|
284
284
|
(0, testsUtil_1.cleanupTestResources)(testContext);
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
|
-
|
|
287
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
288
|
+
await (0, runUtils_1.logTestResults)(results, parsed, commandStartTime, generateRunCommandTemplate(parsed, results), apiClient, workspaceId, browserType);
|
|
288
289
|
if (!testRunnerConfig.keepBrowserOpen) {
|
|
289
290
|
if (!results.success) {
|
|
290
291
|
process.exit(1);
|
|
@@ -9,7 +9,7 @@ const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
|
9
9
|
const reporter_1 = require("../../../reporters/reporter");
|
|
10
10
|
const testsUtil_1 = require("../testsUtil");
|
|
11
11
|
const execution_1 = require("../../../execution");
|
|
12
|
-
async function logTestResults(results, parsed, commandStartTime, rerunCommandTemplate) {
|
|
12
|
+
async function logTestResults(results, parsed, commandStartTime, rerunCommandTemplate, apiClient, workspaceId, browser) {
|
|
13
13
|
loggingProvider_1.logger.logNewLine();
|
|
14
14
|
loggingProvider_1.logger.info(`Test count: ${results.numTotalTests}`);
|
|
15
15
|
loggingProvider_1.logger.info(`Passed: ${results.numPassedTests}`);
|
|
@@ -42,7 +42,7 @@ async function logTestResults(results, parsed, commandStartTime, rerunCommandTem
|
|
|
42
42
|
}
|
|
43
43
|
loggingProvider_1.logger.info(`Total time: ${(0, testsUtil_1.calculateTotalTimeSeconds)(commandStartTime, Date.now())} seconds`);
|
|
44
44
|
if (parsed.reporter) {
|
|
45
|
-
await (0, reporter_1.handleReportingForTestsRun)(parsed.reporter, results, parsed['reporter-options']);
|
|
45
|
+
await (0, reporter_1.handleReportingForTestsRun)(parsed.reporter, results, apiClient, workspaceId, parsed['reporter-options'], browser);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
exports.logTestResults = logTestResults;
|
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = exports.executableSnippetToApiTestSnippet = exports.executableSnippetsToPostmanEvent = exports.apiTestAuthToPostmanAuth = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isBinary = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray =
|
|
6
|
+
exports.splitLines = exports.PRE_REQUEST_LISTEN = exports.convertMablAssertionsToExecArray = exports.convertMablVariableAssignmentsToExecArray = exports.createMablGeneratedScripts = exports.toPostmanScript = exports.replaceVariables = exports.getActualValue = exports.readBody = exports.getResponseContentType = exports.valueToUnquotedString = exports.assertionTypeSupportsCaseSensitivity = exports.assertionTargetSupportsCaseSensitivity = exports.humanizeAssertion = exports.getAssertionTargetArgument = exports.assertionHasTest = exports.isValidMablAssertion = exports.normalizeRegExpExpectedValue = exports.normalizeExpectedValue = exports.normalizeAssertionValue = exports.assertionRequiresValue = exports.filterValidMablAssertions = exports.filterValidMablVariableAssignments = exports.isValidMablVariableAssignment = exports.removeMablGeneratedScripts = exports.createEmptyRequestEvent = exports.findFirstMatchingEvent = exports.restoreCustomRequestFields = exports.deduplicateApiTestExecutionResults = exports.createEmptyVariable = exports.createEmptyAssertion = exports.humanizeAssertionType = exports.getAssertionTypesForTarget = exports.caseInsensitiveEquals = exports.compareStringsCaseInsensitive = exports.ASSERT_TYPES = exports.ASSERT_TARGETS = exports.COLLECTION_WITH_FOLDERS_ERROR = exports.HMAC_SHA1_SIGNATURE = exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE = exports.DEFAULT_OAUTH1_VERSION = exports.OAUTH1_AUTH = exports.NO_AUTH = exports.BEARER_TOKEN_AUTH = exports.BASIC_AUTH = exports.API_KEY_AUTH = exports.INHERIT_AUTH_FROM_PARENT_VALUE = exports.MABL_GENERATED_COMMENT = exports.MABL_GENERATED_ASSERTION_TOKEN = exports.TEST_LISTEN = void 0;
|
|
7
|
+
exports.getSnippetReferencesInTest = exports.getSnippetReferencesInCollection = exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = exports.executableSnippetToApiTestSnippet = exports.executableSnippetsToPostmanEvent = exports.apiTestAuthToPostmanAuth = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isBinary = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray = void 0;
|
|
8
8
|
const newman_types_1 = require("./newman-types");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
|
+
const mablApi_1 = require("../../mablApi");
|
|
11
12
|
const encodingUtil_1 = require("../../util/encodingUtil");
|
|
12
13
|
const stepValidation_1 = require("../entityValidation/stepValidation");
|
|
13
14
|
exports.TEST_LISTEN = 'test';
|
|
@@ -744,20 +745,6 @@ function toPostmanScript(assertion) {
|
|
|
744
745
|
.map((script) => script);
|
|
745
746
|
}
|
|
746
747
|
exports.toPostmanScript = toPostmanScript;
|
|
747
|
-
function insertMablAssertionScripts(item) {
|
|
748
|
-
var _a, _b;
|
|
749
|
-
const { eventValue: existingEventValue } = findFirstMatchingEvent(item.event, exports.TEST_LISTEN);
|
|
750
|
-
const eventValue = existingEventValue !== null && existingEventValue !== void 0 ? existingEventValue : createEmptyRequestEvent();
|
|
751
|
-
if (!existingEventValue) {
|
|
752
|
-
(_a = item.event) === null || _a === void 0 ? void 0 : _a.push(eventValue);
|
|
753
|
-
}
|
|
754
|
-
removeMablGeneratedScripts(eventValue);
|
|
755
|
-
eventValue.mablVariables = filterValidMablVariableAssignments(eventValue.mablVariables);
|
|
756
|
-
eventValue.mablAssertions = filterValidMablAssertions(eventValue.mablAssertions);
|
|
757
|
-
const mablScripts = createMablGeneratedScripts(eventValue);
|
|
758
|
-
(_b = eventValue.script.exec) === null || _b === void 0 ? void 0 : _b.push(...mablScripts);
|
|
759
|
-
}
|
|
760
|
-
exports.insertMablAssertionScripts = insertMablAssertionScripts;
|
|
761
748
|
function createMablGeneratedScripts(event) {
|
|
762
749
|
const mablVariables = convertMablVariableAssignmentsToExecArray(event);
|
|
763
750
|
const mablAssertions = convertMablAssertionsToExecArray(event);
|
|
@@ -1104,8 +1091,7 @@ function convertMablSnippetsToExecArray(event, getSnippetFromInvariantId) {
|
|
|
1104
1091
|
: apiTestSnippet;
|
|
1105
1092
|
if (!(snippet === null || snippet === void 0 ? void 0 : snippet.body)) {
|
|
1106
1093
|
if (apiTestSnippet.reusable) {
|
|
1107
|
-
|
|
1108
|
-
return `// Missing snippet ${apiTestSnippet.invariantId}`;
|
|
1094
|
+
throw new Error(`Unable to find reusable snippet with invariant ID ${apiTestSnippet.invariantId}`);
|
|
1109
1095
|
}
|
|
1110
1096
|
return '';
|
|
1111
1097
|
}
|
|
@@ -1348,3 +1334,28 @@ function postmanEventToExecutableSnippets(event) {
|
|
|
1348
1334
|
exports.postmanEventToExecutableSnippets = postmanEventToExecutableSnippets;
|
|
1349
1335
|
const uuid = () => (0, uuid_1.v4)();
|
|
1350
1336
|
exports.uuid = uuid;
|
|
1337
|
+
function getSnippetReferencesInCollection(collection) {
|
|
1338
|
+
var _a, _b;
|
|
1339
|
+
return (((_a = collection.item) !== null && _a !== void 0 ? _a : [])
|
|
1340
|
+
.flatMap((item) => { var _a; return (_a = item.event) !== null && _a !== void 0 ? _a : []; })
|
|
1341
|
+
.concat((_b = collection.event) !== null && _b !== void 0 ? _b : [])
|
|
1342
|
+
.flatMap((event) => { var _a; return (_a = event.mablSnippets) !== null && _a !== void 0 ? _a : []; })
|
|
1343
|
+
.filter((snippet) => snippet.reusable)
|
|
1344
|
+
.map((snippet) => snippet.invariantId)
|
|
1345
|
+
.map((invariantId) => ({
|
|
1346
|
+
id: invariantId,
|
|
1347
|
+
snippetType: mablApi_1.SnippetTypeEnum.Postman,
|
|
1348
|
+
})));
|
|
1349
|
+
}
|
|
1350
|
+
exports.getSnippetReferencesInCollection = getSnippetReferencesInCollection;
|
|
1351
|
+
function getSnippetReferencesInTest(test) {
|
|
1352
|
+
var _a, _b, _c, _d;
|
|
1353
|
+
return ((_b = (_a = test.api_configuration) === null || _a === void 0 ? void 0 : _a.pre_request_snippets) !== null && _b !== void 0 ? _b : [])
|
|
1354
|
+
.concat((_d = (_c = test.api_configuration) === null || _c === void 0 ? void 0 : _c.post_request_snippets) !== null && _d !== void 0 ? _d : [])
|
|
1355
|
+
.filter((snippet) => snippet.reusable)
|
|
1356
|
+
.map(({ invariant_id: invariantId }) => ({
|
|
1357
|
+
id: invariantId,
|
|
1358
|
+
snippetType: mablApi_1.SnippetTypeEnum.Postman,
|
|
1359
|
+
}));
|
|
1360
|
+
}
|
|
1361
|
+
exports.getSnippetReferencesInTest = getSnippetReferencesInTest;
|