@sasjs/cli 3.6.7 → 3.7.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.
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { Target } from '@sasjs/utils';
|
|
2
|
-
|
|
2
|
+
import SASjs from '@sasjs/adapter/node';
|
|
3
|
+
export declare function runTest(target: Target, testRegExps?: string[], outDirectory?: string, flowSourcePath?: string, sasjs?: SASjs): Promise<undefined>;
|
|
4
|
+
export declare const getTestUrl: (target: Target, jobLocation: string) => string;
|
|
@@ -75,7 +75,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
76
|
};
|
|
77
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.runTest = void 0;
|
|
78
|
+
exports.getTestUrl = exports.runTest = void 0;
|
|
79
79
|
var saveOutput_1 = require("./internal/saveOutput");
|
|
80
80
|
var types_1 = require("../../types");
|
|
81
81
|
var file_1 = require("../../utils/file");
|
|
@@ -86,11 +86,11 @@ var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
|
86
86
|
var path_1 = __importDefault(require("path"));
|
|
87
87
|
var chalk_1 = __importDefault(require("chalk"));
|
|
88
88
|
var utils_2 = require("../../utils/utils");
|
|
89
|
-
function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
89
|
+
function runTest(target, testRegExps, outDirectory, flowSourcePath, sasjs) {
|
|
90
90
|
var _a, _b;
|
|
91
91
|
if (testRegExps === void 0) { testRegExps = []; }
|
|
92
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var testFlowData, testFlow, flow,
|
|
93
|
+
var testFlowData, testFlow, flow, authConfig, username, password, sas9CredentialsError, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _c, csvData, csvPath, coverageReportPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
|
|
94
94
|
var _this = this;
|
|
95
95
|
return __generator(this, function (_d) {
|
|
96
96
|
switch (_d.label) {
|
|
@@ -146,15 +146,17 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
146
146
|
})), false);
|
|
147
147
|
if (testFlow.testTearDown)
|
|
148
148
|
flow.push(testFlow.testTearDown);
|
|
149
|
-
sasjs =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
sasjs =
|
|
150
|
+
sasjs ||
|
|
151
|
+
new node_1.default({
|
|
152
|
+
serverUrl: target.serverUrl,
|
|
153
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
154
|
+
appLoc: target.appLoc,
|
|
155
|
+
serverType: target.serverType,
|
|
156
|
+
debug: true,
|
|
157
|
+
contextName: target.contextName,
|
|
158
|
+
useComputeApi: false
|
|
159
|
+
});
|
|
158
160
|
if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 3];
|
|
159
161
|
return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
|
|
160
162
|
case 2:
|
|
@@ -188,7 +190,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
188
190
|
}
|
|
189
191
|
};
|
|
190
192
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(flow, function (test) { return __awaiter(_this, void 0, void 0, function () {
|
|
191
|
-
var sasJobLocation, testTarget, testId, testUrl, printTestUrl;
|
|
193
|
+
var sasJobLocation, testTarget, testId, testUrl, printTestUrl, sasjsResponse, webout, testResults, existingTestTarget;
|
|
192
194
|
var _this = this;
|
|
193
195
|
return __generator(this, function (_a) {
|
|
194
196
|
switch (_a.label) {
|
|
@@ -202,120 +204,163 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
202
204
|
.pop()
|
|
203
205
|
.replace(/(.test)?(.\d+)?(.sas)?$/i, '');
|
|
204
206
|
testId = (0, utils_1.uuidv4)();
|
|
205
|
-
testUrl =
|
|
206
|
-
? 'SASJobExecution'
|
|
207
|
-
: 'SASStoredProcess', "/?_program=").concat(sasJobLocation, "&_debug=2477");
|
|
207
|
+
testUrl = (0, exports.getTestUrl)(target, sasJobLocation);
|
|
208
208
|
if (target.contextName) {
|
|
209
209
|
testUrl = "".concat(testUrl, "&_contextName=").concat(encodeURIComponent(target.contextName));
|
|
210
210
|
}
|
|
211
211
|
printTestUrl = function () { return process.logger.info("Test URL: ".concat(testUrl)); };
|
|
212
212
|
printTestUrl();
|
|
213
|
-
return [
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
251
|
-
}
|
|
213
|
+
if (!(target.serverType === utils_1.ServerType.Sasjs)) return [3 /*break*/, 2];
|
|
214
|
+
return [4 /*yield*/, sasjs.executeJobSASjs({
|
|
215
|
+
_program: sasJobLocation,
|
|
216
|
+
_debug: 131
|
|
217
|
+
})];
|
|
218
|
+
case 1:
|
|
219
|
+
sasjsResponse = _a.sent();
|
|
220
|
+
if (sasjsResponse._webout) {
|
|
221
|
+
webout = void 0;
|
|
222
|
+
try {
|
|
223
|
+
webout = JSON.parse(sasjsResponse._webout);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
return [2 /*return*/, Promise.reject("SASjs Server responded with invalid json")];
|
|
227
|
+
}
|
|
228
|
+
testResults = webout.test_results;
|
|
229
|
+
if (testResults) {
|
|
230
|
+
existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
|
|
231
|
+
return testResult.test_target === testTarget;
|
|
232
|
+
});
|
|
233
|
+
if (existingTestTarget) {
|
|
234
|
+
existingTestTarget.results.push({
|
|
235
|
+
test_loc: test,
|
|
236
|
+
sasjs_test_id: testId,
|
|
237
|
+
result: testResults,
|
|
238
|
+
test_url: testUrl
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
result.sasjs_test_meta.push({
|
|
243
|
+
test_target: testTarget,
|
|
244
|
+
results: [
|
|
245
|
+
{
|
|
246
|
+
test_loc: test,
|
|
247
|
+
sasjs_test_id: testId,
|
|
248
|
+
result: testResults,
|
|
249
|
+
test_url: testUrl
|
|
252
250
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
251
|
+
]
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return [3 /*break*/, 4];
|
|
257
|
+
case 2: return [4 /*yield*/, sasjs
|
|
258
|
+
.request(sasJobLocation, {}, { username: username, password: password }, function () {
|
|
259
|
+
(0, displayResult_1.displayError)(null, 'Login callback called. Request failed.');
|
|
260
|
+
}, authConfig, ['log'])
|
|
261
|
+
.then(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
262
|
+
var lineBreak, existingTestTarget, existingTestTarget;
|
|
263
|
+
var _a, _b;
|
|
264
|
+
return __generator(this, function (_c) {
|
|
265
|
+
switch (_c.label) {
|
|
266
|
+
case 0:
|
|
267
|
+
lineBreak = true;
|
|
268
|
+
if (!res.result) {
|
|
269
|
+
(0, displayResult_1.displayError)({}, "Job did not return a response, to debug click ".concat(testUrl));
|
|
270
|
+
printCodeExample();
|
|
271
|
+
lineBreak = false;
|
|
272
|
+
existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
|
|
273
|
+
return testResult.test_target === testTarget;
|
|
274
|
+
});
|
|
275
|
+
if (existingTestTarget) {
|
|
276
|
+
existingTestTarget.results.push({
|
|
277
|
+
test_loc: test,
|
|
278
|
+
sasjs_test_id: testId,
|
|
279
|
+
result: types_1.TestResultStatus.notProvided,
|
|
280
|
+
test_url: testUrl
|
|
264
281
|
});
|
|
265
|
-
if (existingTestTarget) {
|
|
266
|
-
existingTestTarget.results.push({
|
|
267
|
-
test_loc: test,
|
|
268
|
-
sasjs_test_id: testId,
|
|
269
|
-
result: res.result.test_results,
|
|
270
|
-
test_url: testUrl
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
result.sasjs_test_meta.push({
|
|
275
|
-
test_target: testTarget,
|
|
276
|
-
results: [
|
|
277
|
-
{
|
|
278
|
-
test_loc: test,
|
|
279
|
-
sasjs_test_id: testId,
|
|
280
|
-
result: res.result.test_results,
|
|
281
|
-
test_url: testUrl
|
|
282
|
-
}
|
|
283
|
-
]
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
282
|
}
|
|
287
283
|
else {
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
result.sasjs_test_meta.push({
|
|
285
|
+
test_target: testTarget,
|
|
286
|
+
results: [
|
|
287
|
+
{
|
|
288
|
+
test_loc: test,
|
|
289
|
+
sasjs_test_id: testId,
|
|
290
|
+
result: types_1.TestResultStatus.notProvided,
|
|
291
|
+
test_url: testUrl
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
});
|
|
290
295
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
296
|
+
}
|
|
297
|
+
if (!((_a = res.result) === null || _a === void 0 ? void 0 : _a.test_results))
|
|
298
|
+
lineBreak = false;
|
|
299
|
+
if (!res.log) return [3 /*break*/, 2];
|
|
300
|
+
return [4 /*yield*/, (0, saveOutput_1.saveLog)(outDirectory, test, res.log, lineBreak)];
|
|
301
|
+
case 1:
|
|
302
|
+
_c.sent();
|
|
303
|
+
_c.label = 2;
|
|
304
|
+
case 2:
|
|
305
|
+
if ((_b = res.result) === null || _b === void 0 ? void 0 : _b.test_results) {
|
|
306
|
+
existingTestTarget = result.sasjs_test_meta.find(function (testResult) {
|
|
307
|
+
return testResult.test_target === testTarget;
|
|
308
|
+
});
|
|
309
|
+
if (existingTestTarget) {
|
|
310
|
+
existingTestTarget.results.push({
|
|
311
|
+
test_loc: test,
|
|
312
|
+
sasjs_test_id: testId,
|
|
313
|
+
result: res.result.test_results,
|
|
314
|
+
test_url: testUrl
|
|
315
|
+
});
|
|
303
316
|
}
|
|
304
317
|
else {
|
|
305
|
-
|
|
318
|
+
result.sasjs_test_meta.push({
|
|
319
|
+
test_target: testTarget,
|
|
320
|
+
results: [
|
|
321
|
+
{
|
|
322
|
+
test_loc: test,
|
|
323
|
+
sasjs_test_id: testId,
|
|
324
|
+
result: res.result.test_results,
|
|
325
|
+
test_url: testUrl
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
});
|
|
306
329
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
(0, displayResult_1.displayError)({}, "'test_results' not found in server response, to debug click ".concat(testUrl));
|
|
333
|
+
printCodeExample();
|
|
334
|
+
}
|
|
335
|
+
return [2 /*return*/];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}); })
|
|
339
|
+
.catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
340
|
+
var _a, _b;
|
|
341
|
+
return __generator(this, function (_c) {
|
|
342
|
+
switch (_c.label) {
|
|
343
|
+
case 0:
|
|
344
|
+
printTestUrl();
|
|
345
|
+
if (err && err.errorCode === 404) {
|
|
346
|
+
(0, utils_2.displaySasjsRunnerError)(username);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
(0, displayResult_1.displayError)({}, "An error occurred while executing the request. Job location: ".concat(sasJobLocation));
|
|
350
|
+
}
|
|
351
|
+
if (!((_b = (_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.result)) return [3 /*break*/, 2];
|
|
352
|
+
return [4 /*yield*/, (0, saveOutput_1.saveLog)(outDirectory, test, err.error.details.result)];
|
|
353
|
+
case 1:
|
|
354
|
+
_c.sent();
|
|
355
|
+
_c.label = 2;
|
|
356
|
+
case 2: return [2 /*return*/];
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}); })];
|
|
360
|
+
case 3:
|
|
317
361
|
_a.sent();
|
|
318
|
-
|
|
362
|
+
_a.label = 4;
|
|
363
|
+
case 4: return [2 /*return*/];
|
|
319
364
|
}
|
|
320
365
|
});
|
|
321
366
|
}); })];
|
|
@@ -367,3 +412,11 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
367
412
|
});
|
|
368
413
|
}
|
|
369
414
|
exports.runTest = runTest;
|
|
415
|
+
var getTestUrl = function (target, jobLocation) {
|
|
416
|
+
return "".concat(target.serverUrl, "/").concat(target.serverType === utils_1.ServerType.SasViya
|
|
417
|
+
? 'SASJobExecution'
|
|
418
|
+
: target.serverType === utils_1.ServerType.Sas9
|
|
419
|
+
? 'SASStoredProcess'
|
|
420
|
+
: 'SASjsApi/stp/execute', "/?_program=").concat(jobLocation, "&_debug=2477");
|
|
421
|
+
};
|
|
422
|
+
exports.getTestUrl = getTestUrl;
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@sasjs/adapter": "3.
|
|
52
|
+
"@sasjs/adapter": "3.5.0",
|
|
53
53
|
"@sasjs/core": "3.10.0",
|
|
54
54
|
"@sasjs/lint": "1.11.2",
|
|
55
55
|
"@sasjs/utils": "2.36.0",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"typescript": "4.5.4",
|
|
98
98
|
"util": "0.12.4"
|
|
99
99
|
},
|
|
100
|
-
"version": "3.
|
|
100
|
+
"version": "3.7.0"
|
|
101
101
|
}
|