@featurevisor/core 1.35.3 → 2.0.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/README.md +0 -6
- package/coverage/clover.xml +321 -237
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/index.html +77 -47
- package/coverage/lcov-report/lib/builder/allocator.js.html +14 -14
- package/coverage/lcov-report/lib/builder/index.html +16 -16
- package/coverage/lcov-report/lib/builder/revision.js.html +3 -3
- package/coverage/lcov-report/lib/builder/traffic.js.html +88 -64
- package/coverage/lcov-report/lib/list/index.html +116 -0
- package/coverage/lcov-report/lib/{tester → list}/matrix.js.html +90 -66
- package/coverage/lcov-report/lib/tester/helpers.js.html +295 -0
- package/coverage/lcov-report/lib/tester/index.html +20 -35
- package/coverage/lcov-report/src/builder/allocator.ts.html +2 -2
- package/coverage/lcov-report/src/builder/index.html +15 -15
- package/coverage/lcov-report/src/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/src/builder/traffic.ts.html +96 -24
- package/coverage/lcov-report/src/list/index.html +116 -0
- package/coverage/lcov-report/src/{tester → list}/matrix.ts.html +87 -21
- package/coverage/lcov-report/src/tester/helpers.ts.html +313 -0
- package/coverage/lcov-report/src/tester/index.html +20 -35
- package/coverage/lcov.info +592 -436
- package/lib/assess-distribution/index.d.ts +1 -1
- package/lib/assess-distribution/index.js +102 -162
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.js +87 -143
- package/lib/benchmark/index.js.map +1 -1
- package/lib/builder/allocator.d.ts +1 -1
- package/lib/builder/allocator.js +12 -12
- package/lib/builder/allocator.js.map +1 -1
- package/lib/builder/allocator.spec.js +22 -22
- package/lib/builder/allocator.spec.js.map +1 -1
- package/lib/builder/buildDatafile.d.ts +4 -3
- package/lib/builder/buildDatafile.js +311 -388
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +2 -1
- package/lib/builder/buildProject.js +96 -183
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/convertToV1.d.ts +10 -0
- package/lib/builder/convertToV1.js +119 -0
- package/lib/builder/convertToV1.js.map +1 -0
- package/lib/builder/getFeatureRanges.d.ts +1 -1
- package/lib/builder/getFeatureRanges.js +32 -105
- package/lib/builder/getFeatureRanges.js.map +1 -1
- package/lib/builder/hashes.d.ts +4 -0
- package/lib/builder/hashes.js +70 -0
- package/lib/builder/hashes.js.map +1 -0
- package/lib/builder/revision.js +2 -2
- package/lib/builder/revision.js.map +1 -1
- package/lib/builder/revision.spec.js +1 -1
- package/lib/builder/revision.spec.js.map +1 -1
- package/lib/builder/traffic.d.ts +1 -1
- package/lib/builder/traffic.js +57 -49
- package/lib/builder/traffic.js.map +1 -1
- package/lib/builder/traffic.spec.js +14 -14
- package/lib/builder/traffic.spec.js.map +1 -1
- package/lib/cli/cli.js +60 -129
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/plugins.js +14 -16
- package/lib/cli/plugins.js.map +1 -1
- package/lib/config/parsers.js +1 -1
- package/lib/config/parsers.js.map +1 -1
- package/lib/config/projectConfig.d.ts +8 -6
- package/lib/config/projectConfig.js +31 -72
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +1 -1
- package/lib/datasource/adapter.js +2 -5
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/datasource.d.ts +2 -1
- package/lib/datasource/datasource.js +107 -148
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.d.ts +1 -1
- package/lib/datasource/filesystemAdapter.js +224 -360
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/evaluate/index.d.ts +1 -1
- package/lib/evaluate/index.js +120 -188
- package/lib/evaluate/index.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.d.ts +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +40 -128
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-duplicate-segments/index.js +27 -82
- package/lib/find-duplicate-segments/index.js.map +1 -1
- package/lib/find-usage/index.d.ts +7 -5
- package/lib/find-usage/index.js +333 -507
- package/lib/find-usage/index.js.map +1 -1
- package/lib/generate-code/index.js +36 -91
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.js +117 -157
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/info/index.js +45 -133
- package/lib/info/index.js.map +1 -1
- package/lib/init/index.d.ts +1 -1
- package/lib/init/index.js +16 -64
- package/lib/init/index.js.map +1 -1
- package/lib/linter/attributeSchema.d.ts +21 -6
- package/lib/linter/attributeSchema.js +18 -4
- package/lib/linter/attributeSchema.js.map +1 -1
- package/lib/linter/checkCircularDependency.d.ts +1 -1
- package/lib/linter/checkCircularDependency.js +22 -80
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/linter/checkPercentageExceedingSlot.d.ts +1 -1
- package/lib/linter/checkPercentageExceedingSlot.js +36 -76
- package/lib/linter/checkPercentageExceedingSlot.js.map +1 -1
- package/lib/linter/conditionSchema.d.ts +1 -1
- package/lib/linter/conditionSchema.js +89 -41
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +345 -197
- package/lib/linter/featureSchema.js +313 -172
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/groupSchema.js +6 -6
- package/lib/linter/groupSchema.js.map +1 -1
- package/lib/linter/lintProject.js +306 -480
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/printError.js +7 -7
- package/lib/linter/printError.js.map +1 -1
- package/lib/linter/segmentSchema.js +2 -2
- package/lib/linter/segmentSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +155 -3
- package/lib/linter/testSchema.js +47 -17
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/index.d.ts +1 -0
- package/lib/list/index.js +349 -517
- package/lib/list/index.js.map +1 -1
- package/lib/{tester → list}/matrix.d.ts +1 -1
- package/lib/{tester → list}/matrix.js +50 -42
- package/lib/list/matrix.js.map +1 -0
- package/lib/{tester → list}/matrix.spec.js +7 -7
- package/lib/list/matrix.spec.js.map +1 -0
- package/lib/site/exportSite.js +25 -71
- package/lib/site/exportSite.js.map +1 -1
- package/lib/site/generateHistory.d.ts +1 -1
- package/lib/site/generateHistory.js +26 -82
- package/lib/site/generateHistory.js.map +1 -1
- package/lib/site/generateSiteSearchIndex.d.ts +1 -1
- package/lib/site/generateSiteSearchIndex.js +182 -259
- package/lib/site/generateSiteSearchIndex.js.map +1 -1
- package/lib/site/getLastModifiedFromHistory.d.ts +1 -1
- package/lib/site/getLastModifiedFromHistory.js +2 -2
- package/lib/site/getLastModifiedFromHistory.js.map +1 -1
- package/lib/site/getOwnerAndRepoFromUrl.js +6 -6
- package/lib/site/getOwnerAndRepoFromUrl.js.map +1 -1
- package/lib/site/getRelativePaths.js +7 -7
- package/lib/site/getRelativePaths.js.map +1 -1
- package/lib/site/getRepoDetails.js +20 -20
- package/lib/site/getRepoDetails.js.map +1 -1
- package/lib/site/index.js +25 -73
- package/lib/site/index.js.map +1 -1
- package/lib/site/serveSite.js +10 -10
- package/lib/site/serveSite.js.map +1 -1
- package/lib/tester/helpers.d.ts +2 -0
- package/lib/tester/helpers.js +71 -0
- package/lib/tester/helpers.js.map +1 -0
- package/lib/tester/helpers.spec.js +115 -0
- package/lib/tester/helpers.spec.js.map +1 -0
- package/lib/tester/index.d.ts +0 -1
- package/lib/tester/index.js +0 -1
- package/lib/tester/index.js.map +1 -1
- package/lib/tester/prettyDuration.js +11 -11
- package/lib/tester/prettyDuration.js.map +1 -1
- package/lib/tester/printTestResult.d.ts +1 -1
- package/lib/tester/printTestResult.js +35 -15
- package/lib/tester/printTestResult.js.map +1 -1
- package/lib/tester/testFeature.d.ts +4 -2
- package/lib/tester/testFeature.js +264 -226
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +3 -7
- package/lib/tester/testProject.js +145 -246
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +5 -2
- package/lib/tester/testSegment.js +65 -102
- package/lib/tester/testSegment.js.map +1 -1
- package/lib/utils/extractKeys.d.ts +2 -1
- package/lib/utils/extractKeys.js +57 -12
- package/lib/utils/extractKeys.js.map +1 -1
- package/lib/utils/git.d.ts +1 -1
- package/lib/utils/git.js +23 -23
- package/lib/utils/git.js.map +1 -1
- package/lib/utils/pretty.js +2 -4
- package/lib/utils/pretty.js.map +1 -1
- package/package.json +5 -6
- package/src/assess-distribution/index.ts +3 -2
- package/src/benchmark/index.ts +3 -3
- package/src/builder/allocator.spec.ts +1 -1
- package/src/builder/allocator.ts +1 -1
- package/src/builder/buildDatafile.ts +161 -124
- package/src/builder/buildProject.ts +6 -3
- package/src/builder/convertToV1.ts +166 -0
- package/src/builder/getFeatureRanges.ts +1 -1
- package/src/builder/hashes.ts +109 -0
- package/src/builder/traffic.ts +40 -16
- package/src/cli/cli.ts +1 -1
- package/src/cli/plugins.ts +0 -2
- package/src/config/projectConfig.ts +13 -10
- package/src/datasource/adapter.ts +1 -1
- package/src/datasource/datasource.ts +23 -2
- package/src/datasource/filesystemAdapter.ts +11 -12
- package/src/evaluate/index.ts +7 -6
- package/src/find-duplicate-segments/findDuplicateSegments.ts +1 -1
- package/src/find-usage/index.ts +111 -44
- package/src/generate-code/index.ts +1 -3
- package/src/generate-code/typescript.ts +7 -29
- package/src/index.ts +0 -1
- package/src/info/index.ts +2 -2
- package/src/init/index.ts +2 -2
- package/src/linter/attributeSchema.ts +18 -2
- package/src/linter/checkCircularDependency.ts +1 -1
- package/src/linter/checkPercentageExceedingSlot.ts +28 -8
- package/src/linter/conditionSchema.ts +66 -10
- package/src/linter/featureSchema.ts +312 -116
- package/src/linter/lintProject.ts +9 -4
- package/src/linter/testSchema.ts +42 -3
- package/src/list/index.ts +18 -30
- package/src/{tester → list}/matrix.ts +33 -11
- package/src/site/exportSite.ts +2 -4
- package/src/site/generateHistory.ts +1 -1
- package/src/site/generateSiteSearchIndex.ts +58 -50
- package/src/site/getLastModifiedFromHistory.ts +1 -1
- package/src/tester/helpers.spec.ts +149 -0
- package/src/tester/helpers.ts +76 -0
- package/src/tester/index.ts +0 -1
- package/src/tester/printTestResult.ts +25 -3
- package/src/tester/testFeature.ts +270 -124
- package/src/tester/testProject.ts +28 -49
- package/src/tester/testSegment.ts +48 -40
- package/src/utils/extractKeys.ts +58 -1
- package/src/utils/git.ts +1 -1
- package/tsconfig.cjs.json +1 -0
- package/coverage/lcov-report/lib/tester/checkIfObjectsAreEqual.js.html +0 -151
- package/coverage/lcov-report/src/tester/checkIfObjectsAreEqual.ts.html +0 -157
- package/lib/restore/index.d.ts +0 -4
- package/lib/restore/index.js +0 -91
- package/lib/restore/index.js.map +0 -1
- package/lib/tester/checkIfArraysAreEqual.d.ts +0 -1
- package/lib/tester/checkIfArraysAreEqual.js +0 -18
- package/lib/tester/checkIfArraysAreEqual.js.map +0 -1
- package/lib/tester/checkIfObjectsAreEqual.d.ts +0 -1
- package/lib/tester/checkIfObjectsAreEqual.js +0 -23
- package/lib/tester/checkIfObjectsAreEqual.js.map +0 -1
- package/lib/tester/checkIfObjectsAreEqual.spec.js +0 -26
- package/lib/tester/checkIfObjectsAreEqual.spec.js.map +0 -1
- package/lib/tester/matrix.js.map +0 -1
- package/lib/tester/matrix.spec.js.map +0 -1
- package/src/restore/index.ts +0 -42
- package/src/tester/checkIfArraysAreEqual.ts +0 -16
- package/src/tester/checkIfObjectsAreEqual.spec.ts +0 -31
- package/src/tester/checkIfObjectsAreEqual.ts +0 -24
- /package/lib/{tester → list}/matrix.spec.d.ts +0 -0
- /package/lib/tester/{checkIfObjectsAreEqual.spec.d.ts → helpers.spec.d.ts} +0 -0
- /package/src/{tester → list}/matrix.spec.ts +0 -0
|
@@ -1,258 +1,157 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.testPlugin = void 0;
|
|
40
4
|
exports.executeTest = executeTest;
|
|
41
5
|
exports.testProject = testProject;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function executeTest(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// show failed only
|
|
99
|
-
if (!testResult.passed) {
|
|
100
|
-
(0, printTestResult_1.printTestResult)(testResult, relativeTestFilePath, rootDirectoryPath);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!testResult.passed) {
|
|
104
|
-
executionResult.passed = false;
|
|
105
|
-
executionResult.assertionsCount.failed = testResult.assertions.filter(function (a) { return !a.passed; }).length;
|
|
106
|
-
executionResult.assertionsCount.passed +=
|
|
107
|
-
testResult.assertions.length - executionResult.assertionsCount.failed;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
executionResult.assertionsCount.passed = testResult.assertions.length;
|
|
111
|
-
}
|
|
112
|
-
return [2 /*return*/, executionResult];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const testSegment_1 = require("./testSegment");
|
|
8
|
+
const testFeature_1 = require("./testFeature");
|
|
9
|
+
const cliFormat_1 = require("./cliFormat");
|
|
10
|
+
const prettyDuration_1 = require("./prettyDuration");
|
|
11
|
+
const printTestResult_1 = require("./printTestResult");
|
|
12
|
+
const builder_1 = require("../builder");
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
const list_1 = require("../list");
|
|
15
|
+
async function executeTest(test, deps, options, datafileContentByEnvironment) {
|
|
16
|
+
const { datasource, projectConfig, rootDirectoryPath } = deps;
|
|
17
|
+
const extension = datasource.getExtension();
|
|
18
|
+
const relativeTestFilePath = test.key + (extension ? `.${extension}` : "");
|
|
19
|
+
const tAsSegment = test;
|
|
20
|
+
const tAsFeature = test;
|
|
21
|
+
const key = tAsSegment.segment || tAsFeature.feature;
|
|
22
|
+
const type = tAsSegment.segment ? "segment" : "feature";
|
|
23
|
+
const executionResult = {
|
|
24
|
+
passed: true,
|
|
25
|
+
assertionsCount: {
|
|
26
|
+
passed: 0,
|
|
27
|
+
failed: 0,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
if (!key) {
|
|
31
|
+
console.error(` => Invalid test: ${JSON.stringify(test)}`);
|
|
32
|
+
executionResult.passed = false;
|
|
33
|
+
return executionResult;
|
|
34
|
+
}
|
|
35
|
+
let testResult;
|
|
36
|
+
if (type === "segment") {
|
|
37
|
+
testResult = await (0, testSegment_1.testSegment)(datasource, tAsSegment, options);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
testResult = await (0, testFeature_1.testFeature)(datasource, projectConfig, tAsFeature, options, datafileContentByEnvironment);
|
|
41
|
+
}
|
|
42
|
+
if (!options.onlyFailures) {
|
|
43
|
+
// show all
|
|
44
|
+
(0, printTestResult_1.printTestResult)(testResult, relativeTestFilePath, rootDirectoryPath);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// show failed only
|
|
48
|
+
if (!testResult.passed) {
|
|
49
|
+
(0, printTestResult_1.printTestResult)(testResult, relativeTestFilePath, rootDirectoryPath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!testResult.passed) {
|
|
53
|
+
executionResult.passed = false;
|
|
54
|
+
executionResult.assertionsCount.failed = testResult.assertions.filter((a) => !a.passed).length;
|
|
55
|
+
executionResult.assertionsCount.passed +=
|
|
56
|
+
testResult.assertions.length - executionResult.assertionsCount.failed;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
executionResult.assertionsCount.passed = testResult.assertions.length;
|
|
60
|
+
}
|
|
61
|
+
return executionResult;
|
|
116
62
|
}
|
|
117
|
-
function testProject(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return [3 /*break*/, 12];
|
|
197
|
-
}
|
|
198
|
-
if (executionResult.passed) {
|
|
199
|
-
passedTestsCount += 1;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
hasError = true;
|
|
203
|
-
failedTestsCount += 1;
|
|
204
|
-
}
|
|
205
|
-
passedAssertionsCount += executionResult.assertionsCount.passed;
|
|
206
|
-
failedAssertionsCount += executionResult.assertionsCount.failed;
|
|
207
|
-
_c.label = 12;
|
|
208
|
-
case 12:
|
|
209
|
-
_b++;
|
|
210
|
-
return [3 /*break*/, 10];
|
|
211
|
-
case 13:
|
|
212
|
-
diffInMs = Date.now() - startTime;
|
|
213
|
-
if (options.onlyFailures !== true || hasError) {
|
|
214
|
-
console.log("\n---");
|
|
215
|
-
}
|
|
216
|
-
console.log("");
|
|
217
|
-
testSpecsMessage = "Test specs: ".concat(passedTestsCount, " passed, ").concat(failedTestsCount, " failed");
|
|
218
|
-
testAssertionsMessage = "Assertions: ".concat(passedAssertionsCount, " passed, ").concat(failedAssertionsCount, " failed");
|
|
219
|
-
if (hasError) {
|
|
220
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, testSpecsMessage);
|
|
221
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, testAssertionsMessage);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
console.log(cliFormat_1.CLI_FORMAT_GREEN, testSpecsMessage);
|
|
225
|
-
console.log(cliFormat_1.CLI_FORMAT_GREEN, testAssertionsMessage);
|
|
226
|
-
}
|
|
227
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD, "Time: ".concat((0, prettyDuration_1.prettyDuration)(diffInMs)));
|
|
228
|
-
return [2 /*return*/, hasError];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
});
|
|
63
|
+
async function testProject(deps, testOptions = {}) {
|
|
64
|
+
const { rootDirectoryPath, projectConfig, datasource, options } = deps;
|
|
65
|
+
let hasError = false;
|
|
66
|
+
if (!fs.existsSync(projectConfig.testsDirectoryPath)) {
|
|
67
|
+
console.error(`Tests directory does not exist: ${projectConfig.testsDirectoryPath}`);
|
|
68
|
+
hasError = true;
|
|
69
|
+
return hasError;
|
|
70
|
+
}
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
let passedTestsCount = 0;
|
|
73
|
+
let failedTestsCount = 0;
|
|
74
|
+
let passedAssertionsCount = 0;
|
|
75
|
+
let failedAssertionsCount = 0;
|
|
76
|
+
const datafileContentByEnvironment = new Map();
|
|
77
|
+
// with environments
|
|
78
|
+
if (Array.isArray(projectConfig.environments)) {
|
|
79
|
+
for (const environment of projectConfig.environments) {
|
|
80
|
+
const existingState = await datasource.readState(environment);
|
|
81
|
+
const datafileContent = await (0, builder_1.buildDatafile)(projectConfig, datasource, {
|
|
82
|
+
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
|
|
83
|
+
revision: "include-all-features",
|
|
84
|
+
environment: environment,
|
|
85
|
+
inflate: options.inflate,
|
|
86
|
+
}, existingState);
|
|
87
|
+
datafileContentByEnvironment.set(environment, datafileContent);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// no environments
|
|
91
|
+
if (projectConfig.environments === false) {
|
|
92
|
+
const existingState = await datasource.readState(false);
|
|
93
|
+
const datafileContent = await (0, builder_1.buildDatafile)(projectConfig, datasource, {
|
|
94
|
+
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
|
|
95
|
+
revision: "include-all-features",
|
|
96
|
+
environment: false,
|
|
97
|
+
inflate: options.inflate,
|
|
98
|
+
}, existingState);
|
|
99
|
+
datafileContentByEnvironment.set(false, datafileContent);
|
|
100
|
+
}
|
|
101
|
+
const tests = await (0, list_1.listEntities)({
|
|
102
|
+
rootDirectoryPath,
|
|
103
|
+
projectConfig,
|
|
104
|
+
datasource,
|
|
105
|
+
options: {
|
|
106
|
+
...testOptions,
|
|
107
|
+
applyMatrix: true,
|
|
108
|
+
},
|
|
109
|
+
}, "test");
|
|
110
|
+
for (const test of tests) {
|
|
111
|
+
const executionResult = await executeTest(test, deps, options, datafileContentByEnvironment);
|
|
112
|
+
if (!executionResult) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (executionResult.passed) {
|
|
116
|
+
passedTestsCount += 1;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
hasError = true;
|
|
120
|
+
failedTestsCount += 1;
|
|
121
|
+
}
|
|
122
|
+
passedAssertionsCount += executionResult.assertionsCount.passed;
|
|
123
|
+
failedAssertionsCount += executionResult.assertionsCount.failed;
|
|
124
|
+
}
|
|
125
|
+
const diffInMs = Date.now() - startTime;
|
|
126
|
+
if (options.onlyFailures !== true || hasError) {
|
|
127
|
+
console.log("\n---");
|
|
128
|
+
}
|
|
129
|
+
console.log("");
|
|
130
|
+
const testSpecsMessage = `Test specs: ${passedTestsCount} passed, ${failedTestsCount} failed`;
|
|
131
|
+
const testAssertionsMessage = `Assertions: ${passedAssertionsCount} passed, ${failedAssertionsCount} failed`;
|
|
132
|
+
if (hasError) {
|
|
133
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, testSpecsMessage);
|
|
134
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, testAssertionsMessage);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, testSpecsMessage);
|
|
138
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, testAssertionsMessage);
|
|
139
|
+
}
|
|
140
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, `Time: ${(0, prettyDuration_1.prettyDuration)(diffInMs)}`);
|
|
141
|
+
return hasError;
|
|
232
142
|
}
|
|
233
143
|
exports.testPlugin = {
|
|
234
144
|
command: "test",
|
|
235
|
-
handler: function (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
options: parsed,
|
|
246
|
-
}, parsed)];
|
|
247
|
-
case 1:
|
|
248
|
-
hasError = _c.sent();
|
|
249
|
-
if (hasError) {
|
|
250
|
-
return [2 /*return*/, false];
|
|
251
|
-
}
|
|
252
|
-
return [2 /*return*/];
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|
|
145
|
+
handler: async function ({ rootDirectoryPath, projectConfig, datasource, parsed }) {
|
|
146
|
+
const hasError = await testProject({
|
|
147
|
+
rootDirectoryPath,
|
|
148
|
+
projectConfig,
|
|
149
|
+
datasource,
|
|
150
|
+
options: parsed,
|
|
151
|
+
}, parsed);
|
|
152
|
+
if (hasError) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
256
155
|
},
|
|
257
156
|
examples: [
|
|
258
157
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testProject.js","sourceRoot":"","sources":["../../src/tester/testProject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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AAE,gBAAgB;YACzB,WAAW,EAAE,uBAAuB;SACrC;KACF;CACF,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { TestSegment, TestResult } from "@featurevisor/types";
|
|
1
|
+
import type { TestSegment, TestResult } from "@featurevisor/types";
|
|
2
2
|
import { Datasource } from "../datasource";
|
|
3
|
-
export declare function testSegment(datasource: Datasource, test: TestSegment,
|
|
3
|
+
export declare function testSegment(datasource: Datasource, test: TestSegment, options?: {
|
|
4
|
+
verbose?: boolean;
|
|
5
|
+
quiet?: boolean;
|
|
6
|
+
}): Promise<TestResult>;
|