@sasjs/cli 3.12.3 → 3.12.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.
- package/build/commands/add/spec/addTarget.spec.js +10 -8
- package/build/commands/testing/internal/saveOutput.d.ts +2 -2
- package/build/commands/testing/spec/mockedAdapter/testResponses.js +10 -0
- package/build/commands/testing/spec/testing.spec.js +23 -0
- package/build/commands/testing/test.js +23 -6
- package/build/types/index.d.ts +1 -1
- package/build/types/testing.d.ts +8 -0
- package/build/utils/test.js +3 -0
- package/package.json +2 -2
|
@@ -82,6 +82,7 @@ describe('addTarget', function () {
|
|
|
82
82
|
var viyaTargetName = "test-viya-".concat((0, utils_1.generateTimestamp)());
|
|
83
83
|
var sas9TargetName = "test-sas9-".concat((0, utils_1.generateTimestamp)());
|
|
84
84
|
var sasjsTargetName = "test-server-".concat((0, utils_1.generateTimestamp)());
|
|
85
|
+
var serverUrl = process.env.VIYA_SERVER_URL || '';
|
|
85
86
|
var globalTestTarget;
|
|
86
87
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
88
|
return __generator(this, function (_a) {
|
|
@@ -138,7 +139,7 @@ describe('addTarget', function () {
|
|
|
138
139
|
serverType: utils_1.ServerType.SasViya,
|
|
139
140
|
name: viyaTargetName,
|
|
140
141
|
appLoc: '/Public/app',
|
|
141
|
-
serverUrl:
|
|
142
|
+
serverUrl: serverUrl,
|
|
142
143
|
existingTarget: {}
|
|
143
144
|
};
|
|
144
145
|
jest
|
|
@@ -175,7 +176,7 @@ describe('addTarget', function () {
|
|
|
175
176
|
serverType: utils_1.ServerType.Sasjs,
|
|
176
177
|
name: sasjsTargetName,
|
|
177
178
|
appLoc: '/Public/app',
|
|
178
|
-
serverUrl:
|
|
179
|
+
serverUrl: serverUrl,
|
|
179
180
|
existingTarget: {}
|
|
180
181
|
};
|
|
181
182
|
jest
|
|
@@ -211,7 +212,7 @@ describe('addTarget', function () {
|
|
|
211
212
|
serverType: utils_1.ServerType.Sas9,
|
|
212
213
|
name: sas9TargetName,
|
|
213
214
|
appLoc: '/Public/app',
|
|
214
|
-
serverUrl:
|
|
215
|
+
serverUrl: serverUrl,
|
|
215
216
|
existingTarget: {}
|
|
216
217
|
};
|
|
217
218
|
jest
|
|
@@ -248,7 +249,7 @@ describe('addTarget', function () {
|
|
|
248
249
|
serverType: utils_1.ServerType.SasViya,
|
|
249
250
|
name: viyaTargetName,
|
|
250
251
|
appLoc: '/Public/app',
|
|
251
|
-
serverUrl:
|
|
252
|
+
serverUrl: serverUrl,
|
|
252
253
|
existingTarget: {}
|
|
253
254
|
};
|
|
254
255
|
jest
|
|
@@ -285,12 +286,13 @@ describe('addTarget', function () {
|
|
|
285
286
|
case 1:
|
|
286
287
|
config = _a.sent();
|
|
287
288
|
targetJson = (config.targets || []).find(function (t) { return t.name === 'viya'; });
|
|
289
|
+
targetJson.streamConfig.streamWeb = false;
|
|
288
290
|
commonFields = {
|
|
289
291
|
scope: targetScope_1.TargetScope.Local,
|
|
290
292
|
serverType: utils_1.ServerType.SasViya,
|
|
291
293
|
name: 'viya',
|
|
292
294
|
appLoc: '/Public/app/new/location',
|
|
293
|
-
serverUrl:
|
|
295
|
+
serverUrl: serverUrl,
|
|
294
296
|
existingTarget: targetJson
|
|
295
297
|
};
|
|
296
298
|
jest
|
|
@@ -332,7 +334,7 @@ describe('addTarget', function () {
|
|
|
332
334
|
serverType: utils_1.ServerType.Sas9,
|
|
333
335
|
name: 'sas9',
|
|
334
336
|
appLoc: '/Public/app/new/location/2',
|
|
335
|
-
serverUrl:
|
|
337
|
+
serverUrl: serverUrl,
|
|
336
338
|
existingTarget: target
|
|
337
339
|
};
|
|
338
340
|
jest
|
|
@@ -374,7 +376,7 @@ describe('addTarget', function () {
|
|
|
374
376
|
serverType: utils_1.ServerType.Sasjs,
|
|
375
377
|
name: 'server',
|
|
376
378
|
appLoc: '/Public/app/new/location/2',
|
|
377
|
-
serverUrl:
|
|
379
|
+
serverUrl: serverUrl,
|
|
378
380
|
existingTarget: targetJson
|
|
379
381
|
};
|
|
380
382
|
jest
|
|
@@ -410,7 +412,7 @@ describe('addTarget', function () {
|
|
|
410
412
|
serverType: globalTestTarget.serverType,
|
|
411
413
|
name: globalTestTarget.name,
|
|
412
414
|
appLoc: '/Public/app/new/location/3',
|
|
413
|
-
serverUrl:
|
|
415
|
+
serverUrl: serverUrl,
|
|
414
416
|
existingTarget: globalTestTarget
|
|
415
417
|
};
|
|
416
418
|
jest
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TestResults } from '../../../types';
|
|
1
|
+
import { TestResults, TestResultCsv } from '../../../types';
|
|
2
2
|
export declare const saveLog: (outDirectory: string, test: string, log: string, lineBreak?: boolean) => Promise<void>;
|
|
3
3
|
export declare const saveResultJson: (outDirectory: string, result: TestResults) => Promise<string | false>;
|
|
4
4
|
export declare const saveResultCsv: (outDirectory: string, result: TestResults, options?: {}) => Promise<{
|
|
5
|
-
csvData:
|
|
5
|
+
csvData: TestResultCsv[];
|
|
6
6
|
csvPath: string;
|
|
7
7
|
}>;
|
|
8
8
|
export declare const saveResultXml: (outDirectory: string, result: TestResults) => Promise<string>;
|
|
@@ -19,5 +19,15 @@ exports.testResponses = {
|
|
|
19
19
|
TEST_DESCRIPTION: 'examplemacro test.1 description',
|
|
20
20
|
TEST_RESULT: 'PASS'
|
|
21
21
|
}
|
|
22
|
+
],
|
|
23
|
+
'notexisting.test': [
|
|
24
|
+
{
|
|
25
|
+
TEST_DESCRIPTION: 'examplemacro test.1 description',
|
|
26
|
+
TEST_RESULT: 'PASS'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
TEST_DESCRIPTION: 'examplemacro test.1 description',
|
|
30
|
+
TEST_RESULT: 'FAIL'
|
|
31
|
+
}
|
|
22
32
|
]
|
|
23
33
|
};
|
|
@@ -71,6 +71,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
71
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
72
|
var path_1 = __importDefault(require("path"));
|
|
73
73
|
var test_1 = require("../test");
|
|
74
|
+
var types_1 = require("../../../types");
|
|
74
75
|
var utils_1 = require("@sasjs/utils");
|
|
75
76
|
var test_2 = require("../../../utils/test");
|
|
76
77
|
var setConstants_1 = require("../../../utils/setConstants");
|
|
@@ -78,6 +79,9 @@ var dotenv_1 = __importDefault(require("dotenv"));
|
|
|
78
79
|
var __1 = require("../..");
|
|
79
80
|
var sasJsModules = __importStar(require("../../../utils/createSASjsInstance"));
|
|
80
81
|
var testResponses_1 = require("./mockedAdapter/testResponses");
|
|
82
|
+
var fileModule = __importStar(require("@sasjs/utils/file"));
|
|
83
|
+
var utilsModule = __importStar(require("@sasjs/utils/utils"));
|
|
84
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
81
85
|
describe('sasjs test', function () {
|
|
82
86
|
var expectedCoverageLcov = "TN:testsetup.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:exampleprogram.test.sas\nSF:jobs/jobs/exampleprogram.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:standalone.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:examplemacro.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:shouldFail.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:dostuff.test.0.sas\nSF:services/admin/dostuff.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:dostuff.test.1.sas\nSF:services/admin/dostuff.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:testteardown.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record";
|
|
83
87
|
describe('SASVIYA', function () {
|
|
@@ -576,6 +580,25 @@ describe('sasjs test', function () {
|
|
|
576
580
|
}
|
|
577
581
|
});
|
|
578
582
|
}); });
|
|
583
|
+
it('should FAIL test suit if any test has status FAIL', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
584
|
+
var testService;
|
|
585
|
+
return __generator(this, function (_a) {
|
|
586
|
+
switch (_a.label) {
|
|
587
|
+
case 0:
|
|
588
|
+
testService = 'notexisting';
|
|
589
|
+
jest.spyOn(process.logger, 'table');
|
|
590
|
+
jest.spyOn(utilsModule, 'uuidv4').mockImplementation(function () { return 'uuidv4'; });
|
|
591
|
+
jest.spyOn(fileModule, 'readFile').mockImplementation(function () {
|
|
592
|
+
return Promise.resolve("{\n \"tests\": [\n \"tests/macros/".concat(testService, ".test.sas\"\n ],\n \"testSetUp\": \"\",\n \"testTearDown\": \"\"\n}"));
|
|
593
|
+
});
|
|
594
|
+
return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined)];
|
|
595
|
+
case 1:
|
|
596
|
+
_a.sent();
|
|
597
|
+
expect(process.logger.table).toHaveBeenCalledWith([['uuidv4', testService, chalk_1.default.redBright(types_1.TestResultStatus.fail)]], { head: ['SASjs Test ID', 'Test Target', 'Test Suite Result'] });
|
|
598
|
+
return [2 /*return*/];
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
}); });
|
|
579
602
|
});
|
|
580
603
|
});
|
|
581
604
|
function generateTarget(serverType) {
|
|
@@ -86,11 +86,12 @@ var path_1 = __importDefault(require("path"));
|
|
|
86
86
|
var chalk_1 = __importDefault(require("chalk"));
|
|
87
87
|
var utils_2 = require("../../utils/utils");
|
|
88
88
|
var createSASjsInstance_1 = require("../../utils/createSASjsInstance");
|
|
89
|
+
// interface
|
|
89
90
|
function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
90
91
|
var _a, _b;
|
|
91
92
|
if (testRegExps === void 0) { testRegExps = []; }
|
|
92
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var testFlowData, testFlow, flow, sasjs, authConfig, username, password, _c, sas9CredentialsError, e_1, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _d, csvData, csvPath, coverageReportPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
|
|
94
|
+
var testFlowData, testFlow, flow, sasjs, authConfig, username, password, _c, sas9CredentialsError, e_1, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _d, csvData, csvPath, coverageReportPath, resultTable, testSuites, testsCount, passedTestsCount, testsWithResultsCount;
|
|
94
95
|
var _this = this;
|
|
95
96
|
return __generator(this, function (_e) {
|
|
96
97
|
switch (_e.label) {
|
|
@@ -300,7 +301,8 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
303
|
}
|
|
303
|
-
else if (target.serverType
|
|
304
|
+
else if (target.serverType === utils_1.ServerType.SasViya ||
|
|
305
|
+
target.serverType === utils_1.ServerType.Sas9) {
|
|
304
306
|
(0, displayResult_1.displayError)({}, "'test_results' not found in server response, to debug click ".concat(testUrl));
|
|
305
307
|
printCodeExample();
|
|
306
308
|
}
|
|
@@ -353,11 +355,26 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
353
355
|
coverageReportPath = _e.sent();
|
|
354
356
|
resultTable = {};
|
|
355
357
|
if (Array.isArray(csvData)) {
|
|
356
|
-
csvData.
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
testSuites = csvData.reduce(function (acc, item) {
|
|
359
|
+
if (!acc.filter(function (i) { return i.sasjs_test_id === item.sasjs_test_id; }).length)
|
|
360
|
+
acc.push(item);
|
|
361
|
+
return acc;
|
|
362
|
+
}, []);
|
|
363
|
+
testSuites.forEach(function (test) {
|
|
364
|
+
var passedTests = csvData.filter(function (item) {
|
|
365
|
+
return item.sasjs_test_id === test.sasjs_test_id &&
|
|
366
|
+
item.test_suite_result === types_1.TestResultStatus.pass;
|
|
360
367
|
});
|
|
368
|
+
var failedTests = csvData.filter(function (item) {
|
|
369
|
+
return item.sasjs_test_id === test.sasjs_test_id &&
|
|
370
|
+
item.test_suite_result === types_1.TestResultStatus.fail;
|
|
371
|
+
});
|
|
372
|
+
resultTable[test.sasjs_test_id] = {
|
|
373
|
+
test_target: test.test_target,
|
|
374
|
+
test_suite_result: passedTests.length && !failedTests.length
|
|
375
|
+
? types_1.TestResultStatus.pass
|
|
376
|
+
: types_1.TestResultStatus.fail
|
|
377
|
+
};
|
|
361
378
|
});
|
|
362
379
|
}
|
|
363
380
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.table(Object.keys(resultTable).map(function (key) { return [
|
package/build/types/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { CommandBase } from './command/commandBase';
|
|
|
2
2
|
export { File, FilePath } from './file';
|
|
3
3
|
export { Folder } from './folder';
|
|
4
4
|
export { TargetScope } from './targetScope';
|
|
5
|
-
export { TestFlow, Coverage, CoverageType, CoverageState, TestResults, TestResultStatus, TestDescription, TestResult, TestResultDescription } from './testing';
|
|
5
|
+
export { TestFlow, Coverage, CoverageType, CoverageState, TestResults, TestResultStatus, TestDescription, TestResult, TestResultDescription, TestResultCsv } from './testing';
|
|
6
6
|
export { Flow, FlowWave, FlowWaveJob } from './flow';
|
|
7
7
|
export { ServicePack, ServicePackMember } from './servicePack';
|
package/build/types/testing.d.ts
CHANGED
|
@@ -42,3 +42,11 @@ export interface TestResult {
|
|
|
42
42
|
export interface TestResults {
|
|
43
43
|
sasjs_test_meta: TestDescription[];
|
|
44
44
|
}
|
|
45
|
+
export interface TestResultCsv {
|
|
46
|
+
test_target: string;
|
|
47
|
+
test_loc: string;
|
|
48
|
+
sasjs_test_id: string;
|
|
49
|
+
test_suite_result: TestResultStatus.pass | TestResultStatus.fail;
|
|
50
|
+
test_description: string;
|
|
51
|
+
test_url: string;
|
|
52
|
+
}
|
package/build/utils/test.js
CHANGED
|
@@ -413,6 +413,9 @@ var updateTarget = function (targetJson, targetName, isLocal) {
|
|
|
413
413
|
targetIndex = config.targets.findIndex(function (t) { return t.name === targetName; });
|
|
414
414
|
if (!(targetIndex >= 0)) return [3 /*break*/, 9];
|
|
415
415
|
config.targets.splice(targetIndex, 1, __assign(__assign({}, config.targets[targetIndex]), targetJson));
|
|
416
|
+
config = __assign(__assign({}, config), { targets: config.targets.map(function (target) { return (__assign(__assign({}, target), { serverUrl: process.env["".concat(target.serverType === types_1.ServerType.SasViya
|
|
417
|
+
? 'VIYA'
|
|
418
|
+
: target.serverType, "_SERVER_URL")] })); }) });
|
|
416
419
|
if (!isLocal) return [3 /*break*/, 6];
|
|
417
420
|
return [4 /*yield*/, (0, config_1.saveLocalConfigFile)(JSON.stringify(config, null, 2))];
|
|
418
421
|
case 5:
|
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@sasjs/adapter": "3.8.1",
|
|
51
51
|
"@sasjs/core": "4.15.3",
|
|
52
52
|
"@sasjs/lint": "1.11.2",
|
|
53
|
-
"@sasjs/utils": "2.
|
|
53
|
+
"@sasjs/utils": "2.41.0",
|
|
54
54
|
"chalk": "4.1.2",
|
|
55
55
|
"csv-stringify": "5.6.5",
|
|
56
56
|
"dotenv": "10.0.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"typescript": "4.5.4",
|
|
95
95
|
"util": "0.12.4"
|
|
96
96
|
},
|
|
97
|
-
"version": "3.12.
|
|
97
|
+
"version": "3.12.4"
|
|
98
98
|
}
|