tstyche 3.2.0 → 3.3.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/build/tstyche.d.ts +1 -1
- package/build/tstyche.js +266 -246
- package/package.json +2 -2
package/build/tstyche.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ declare class Diagnostic {
|
|
|
61
61
|
}): this;
|
|
62
62
|
static error(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
|
|
63
63
|
extendWith(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
|
|
64
|
-
static fromDiagnostics(diagnostics: Array<ts.Diagnostic
|
|
64
|
+
static fromDiagnostics(diagnostics: Array<ts.Diagnostic>): Array<Diagnostic>;
|
|
65
65
|
static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
|
|
66
66
|
}
|
|
67
67
|
|
package/build/tstyche.js
CHANGED
|
@@ -75,6 +75,12 @@ class ConfigDiagnosticText {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
var DiagnosticCategory;
|
|
79
|
+
(function (DiagnosticCategory) {
|
|
80
|
+
DiagnosticCategory["Error"] = "error";
|
|
81
|
+
DiagnosticCategory["Warning"] = "warning";
|
|
82
|
+
})(DiagnosticCategory || (DiagnosticCategory = {}));
|
|
83
|
+
|
|
78
84
|
class DiagnosticOrigin {
|
|
79
85
|
assertion;
|
|
80
86
|
end;
|
|
@@ -116,40 +122,42 @@ class Diagnostic {
|
|
|
116
122
|
return this;
|
|
117
123
|
}
|
|
118
124
|
static error(text, origin) {
|
|
119
|
-
return new Diagnostic(text,
|
|
125
|
+
return new Diagnostic(text, DiagnosticCategory.Error, origin);
|
|
120
126
|
}
|
|
121
127
|
extendWith(text, origin) {
|
|
122
128
|
return new Diagnostic([this.text, text].flat(), this.category, origin ?? this.origin);
|
|
123
129
|
}
|
|
124
|
-
static fromDiagnostics(diagnostics
|
|
130
|
+
static fromDiagnostics(diagnostics) {
|
|
125
131
|
return diagnostics.map((diagnostic) => {
|
|
126
132
|
const code = `ts(${diagnostic.code})`;
|
|
127
133
|
let origin;
|
|
128
|
-
if (
|
|
134
|
+
if (diagnostic.file != null && diagnostic.start != null && diagnostic.length != null) {
|
|
129
135
|
origin = new DiagnosticOrigin(diagnostic.start, diagnostic.start + diagnostic.length, diagnostic.file);
|
|
130
136
|
}
|
|
131
137
|
let related;
|
|
132
138
|
if (diagnostic.relatedInformation != null) {
|
|
133
|
-
related = Diagnostic.fromDiagnostics(diagnostic.relatedInformation
|
|
139
|
+
related = Diagnostic.fromDiagnostics(diagnostic.relatedInformation);
|
|
134
140
|
}
|
|
135
|
-
const text =
|
|
136
|
-
|
|
141
|
+
const text = typeof diagnostic.messageText === "string"
|
|
142
|
+
? diagnostic.messageText
|
|
143
|
+
: Diagnostic.#toMessageText(diagnostic.messageText);
|
|
144
|
+
return new Diagnostic(text, DiagnosticCategory.Error, origin).add({ code, related });
|
|
137
145
|
});
|
|
138
146
|
}
|
|
139
|
-
static #
|
|
140
|
-
|
|
147
|
+
static #toMessageText(chain) {
|
|
148
|
+
const result = [chain.messageText];
|
|
149
|
+
if (chain.next != null) {
|
|
150
|
+
for (const nextChain of chain.next) {
|
|
151
|
+
result.push(...Diagnostic.#toMessageText(nextChain));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
141
155
|
}
|
|
142
156
|
static warning(text, origin) {
|
|
143
|
-
return new Diagnostic(text,
|
|
157
|
+
return new Diagnostic(text, DiagnosticCategory.Warning, origin);
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
|
|
147
|
-
var DiagnosticCategory;
|
|
148
|
-
(function (DiagnosticCategory) {
|
|
149
|
-
DiagnosticCategory["Error"] = "error";
|
|
150
|
-
DiagnosticCategory["Warning"] = "warning";
|
|
151
|
-
})(DiagnosticCategory || (DiagnosticCategory = {}));
|
|
152
|
-
|
|
153
161
|
class SourceFile {
|
|
154
162
|
fileName;
|
|
155
163
|
#lineMap;
|
|
@@ -255,6 +263,22 @@ class Path {
|
|
|
255
263
|
}
|
|
256
264
|
}
|
|
257
265
|
|
|
266
|
+
var OptionBrand;
|
|
267
|
+
(function (OptionBrand) {
|
|
268
|
+
OptionBrand["String"] = "string";
|
|
269
|
+
OptionBrand["Number"] = "number";
|
|
270
|
+
OptionBrand["Boolean"] = "boolean";
|
|
271
|
+
OptionBrand["BareTrue"] = "bareTrue";
|
|
272
|
+
OptionBrand["List"] = "list";
|
|
273
|
+
})(OptionBrand || (OptionBrand = {}));
|
|
274
|
+
|
|
275
|
+
var OptionGroup;
|
|
276
|
+
(function (OptionGroup) {
|
|
277
|
+
OptionGroup[OptionGroup["CommandLine"] = 2] = "CommandLine";
|
|
278
|
+
OptionGroup[OptionGroup["ConfigFile"] = 4] = "ConfigFile";
|
|
279
|
+
OptionGroup[OptionGroup["ResolvedConfig"] = 6] = "ResolvedConfig";
|
|
280
|
+
})(OptionGroup || (OptionGroup = {}));
|
|
281
|
+
|
|
258
282
|
class Environment {
|
|
259
283
|
static resolve() {
|
|
260
284
|
return {
|
|
@@ -864,157 +888,157 @@ class Target {
|
|
|
864
888
|
class Options {
|
|
865
889
|
static #definitions = [
|
|
866
890
|
{
|
|
867
|
-
brand:
|
|
891
|
+
brand: OptionBrand.String,
|
|
868
892
|
description: "The Url to the config file validation schema.",
|
|
869
|
-
group:
|
|
893
|
+
group: OptionGroup.ConfigFile,
|
|
870
894
|
name: "$schema",
|
|
871
895
|
},
|
|
872
896
|
{
|
|
873
|
-
brand:
|
|
897
|
+
brand: OptionBrand.Boolean,
|
|
874
898
|
description: "Enable type error reporting for source files.",
|
|
875
|
-
group:
|
|
899
|
+
group: OptionGroup.ConfigFile,
|
|
876
900
|
name: "checkSourceFiles",
|
|
877
901
|
},
|
|
878
902
|
{
|
|
879
|
-
brand:
|
|
903
|
+
brand: OptionBrand.String,
|
|
880
904
|
description: "The path to a TSTyche configuration file.",
|
|
881
|
-
group:
|
|
905
|
+
group: OptionGroup.CommandLine,
|
|
882
906
|
name: "config",
|
|
883
907
|
},
|
|
884
908
|
{
|
|
885
|
-
brand:
|
|
909
|
+
brand: OptionBrand.Boolean,
|
|
886
910
|
description: "Stop running tests after the first failed assertion.",
|
|
887
|
-
group:
|
|
911
|
+
group: OptionGroup.ConfigFile | OptionGroup.CommandLine,
|
|
888
912
|
name: "failFast",
|
|
889
913
|
},
|
|
890
914
|
{
|
|
891
|
-
brand:
|
|
915
|
+
brand: OptionBrand.BareTrue,
|
|
892
916
|
description: "Print the list of command line options with brief descriptions and exit.",
|
|
893
|
-
group:
|
|
917
|
+
group: OptionGroup.CommandLine,
|
|
894
918
|
name: "help",
|
|
895
919
|
},
|
|
896
920
|
{
|
|
897
|
-
brand:
|
|
921
|
+
brand: OptionBrand.BareTrue,
|
|
898
922
|
description: "Install specified versions of the 'typescript' package and exit.",
|
|
899
|
-
group:
|
|
923
|
+
group: OptionGroup.CommandLine,
|
|
900
924
|
name: "install",
|
|
901
925
|
},
|
|
902
926
|
{
|
|
903
|
-
brand:
|
|
927
|
+
brand: OptionBrand.BareTrue,
|
|
904
928
|
description: "Print the list of supported versions of the 'typescript' package and exit.",
|
|
905
|
-
group:
|
|
929
|
+
group: OptionGroup.CommandLine,
|
|
906
930
|
name: "list",
|
|
907
931
|
},
|
|
908
932
|
{
|
|
909
|
-
brand:
|
|
933
|
+
brand: OptionBrand.BareTrue,
|
|
910
934
|
description: "Print the list of the selected test files and exit.",
|
|
911
|
-
group:
|
|
935
|
+
group: OptionGroup.CommandLine,
|
|
912
936
|
name: "listFiles",
|
|
913
937
|
},
|
|
914
938
|
{
|
|
915
|
-
brand:
|
|
939
|
+
brand: OptionBrand.String,
|
|
916
940
|
description: "Only run tests with matching name.",
|
|
917
|
-
group:
|
|
941
|
+
group: OptionGroup.CommandLine,
|
|
918
942
|
name: "only",
|
|
919
943
|
},
|
|
920
944
|
{
|
|
921
|
-
brand:
|
|
945
|
+
brand: OptionBrand.List,
|
|
922
946
|
description: "The list of plugins to use.",
|
|
923
|
-
group:
|
|
947
|
+
group: OptionGroup.CommandLine | OptionGroup.ConfigFile,
|
|
924
948
|
items: {
|
|
925
|
-
brand:
|
|
949
|
+
brand: OptionBrand.String,
|
|
926
950
|
name: "plugins",
|
|
927
951
|
},
|
|
928
952
|
name: "plugins",
|
|
929
953
|
},
|
|
930
954
|
{
|
|
931
|
-
brand:
|
|
955
|
+
brand: OptionBrand.BareTrue,
|
|
932
956
|
description: "Remove all installed versions of the 'typescript' package and exit.",
|
|
933
|
-
group:
|
|
957
|
+
group: OptionGroup.CommandLine,
|
|
934
958
|
name: "prune",
|
|
935
959
|
},
|
|
936
960
|
{
|
|
937
|
-
brand:
|
|
961
|
+
brand: OptionBrand.Boolean,
|
|
938
962
|
description: "Reject the 'any' type passed as an argument to the 'expect()' function or a matcher.",
|
|
939
|
-
group:
|
|
963
|
+
group: OptionGroup.ConfigFile,
|
|
940
964
|
name: "rejectAnyType",
|
|
941
965
|
},
|
|
942
966
|
{
|
|
943
|
-
brand:
|
|
967
|
+
brand: OptionBrand.Boolean,
|
|
944
968
|
description: "Reject the 'never' type passed as an argument to the 'expect()' function or a matcher.",
|
|
945
|
-
group:
|
|
969
|
+
group: OptionGroup.ConfigFile,
|
|
946
970
|
name: "rejectNeverType",
|
|
947
971
|
},
|
|
948
972
|
{
|
|
949
|
-
brand:
|
|
973
|
+
brand: OptionBrand.List,
|
|
950
974
|
description: "The list of reporters to use.",
|
|
951
|
-
group:
|
|
975
|
+
group: OptionGroup.CommandLine | OptionGroup.ConfigFile,
|
|
952
976
|
items: {
|
|
953
|
-
brand:
|
|
977
|
+
brand: OptionBrand.String,
|
|
954
978
|
name: "reporters",
|
|
955
979
|
},
|
|
956
980
|
name: "reporters",
|
|
957
981
|
},
|
|
958
982
|
{
|
|
959
|
-
brand:
|
|
983
|
+
brand: OptionBrand.String,
|
|
960
984
|
description: "The path to a directory containing files of a test project.",
|
|
961
|
-
group:
|
|
985
|
+
group: OptionGroup.ConfigFile,
|
|
962
986
|
name: "rootPath",
|
|
963
987
|
},
|
|
964
988
|
{
|
|
965
|
-
brand:
|
|
989
|
+
brand: OptionBrand.BareTrue,
|
|
966
990
|
description: "Print the resolved configuration and exit.",
|
|
967
|
-
group:
|
|
991
|
+
group: OptionGroup.CommandLine,
|
|
968
992
|
name: "showConfig",
|
|
969
993
|
},
|
|
970
994
|
{
|
|
971
|
-
brand:
|
|
995
|
+
brand: OptionBrand.String,
|
|
972
996
|
description: "Skip tests with matching name.",
|
|
973
|
-
group:
|
|
997
|
+
group: OptionGroup.CommandLine,
|
|
974
998
|
name: "skip",
|
|
975
999
|
},
|
|
976
1000
|
{
|
|
977
|
-
brand:
|
|
1001
|
+
brand: OptionBrand.List,
|
|
978
1002
|
description: "The list of TypeScript versions to be tested on.",
|
|
979
|
-
group:
|
|
1003
|
+
group: OptionGroup.CommandLine | OptionGroup.ConfigFile,
|
|
980
1004
|
items: {
|
|
981
|
-
brand:
|
|
1005
|
+
brand: OptionBrand.String,
|
|
982
1006
|
name: "target",
|
|
983
1007
|
},
|
|
984
1008
|
name: "target",
|
|
985
1009
|
},
|
|
986
1010
|
{
|
|
987
|
-
brand:
|
|
1011
|
+
brand: OptionBrand.List,
|
|
988
1012
|
description: "The list of glob patterns matching the test files.",
|
|
989
|
-
group:
|
|
1013
|
+
group: OptionGroup.ConfigFile,
|
|
990
1014
|
items: {
|
|
991
|
-
brand:
|
|
1015
|
+
brand: OptionBrand.String,
|
|
992
1016
|
name: "testFileMatch",
|
|
993
1017
|
},
|
|
994
1018
|
name: "testFileMatch",
|
|
995
1019
|
},
|
|
996
1020
|
{
|
|
997
|
-
brand:
|
|
1021
|
+
brand: OptionBrand.String,
|
|
998
1022
|
description: "The look up strategy to be used to find the TSConfig file.",
|
|
999
|
-
group:
|
|
1023
|
+
group: OptionGroup.CommandLine | OptionGroup.ConfigFile,
|
|
1000
1024
|
name: "tsconfig",
|
|
1001
1025
|
},
|
|
1002
1026
|
{
|
|
1003
|
-
brand:
|
|
1027
|
+
brand: OptionBrand.BareTrue,
|
|
1004
1028
|
description: "Fetch the 'typescript' package metadata from the registry and exit.",
|
|
1005
|
-
group:
|
|
1029
|
+
group: OptionGroup.CommandLine,
|
|
1006
1030
|
name: "update",
|
|
1007
1031
|
},
|
|
1008
1032
|
{
|
|
1009
|
-
brand:
|
|
1033
|
+
brand: OptionBrand.BareTrue,
|
|
1010
1034
|
description: "Print the version number and exit.",
|
|
1011
|
-
group:
|
|
1035
|
+
group: OptionGroup.CommandLine,
|
|
1012
1036
|
name: "version",
|
|
1013
1037
|
},
|
|
1014
1038
|
{
|
|
1015
|
-
brand:
|
|
1039
|
+
brand: OptionBrand.BareTrue,
|
|
1016
1040
|
description: "Watch for changes and rerun related test files.",
|
|
1017
|
-
group:
|
|
1041
|
+
group: OptionGroup.CommandLine,
|
|
1018
1042
|
name: "watch",
|
|
1019
1043
|
},
|
|
1020
1044
|
];
|
|
@@ -1131,7 +1155,7 @@ class CommandLineParser {
|
|
|
1131
1155
|
this.#commandLineOptions = commandLine;
|
|
1132
1156
|
this.#pathMatch = pathMatch;
|
|
1133
1157
|
this.#onDiagnostics = onDiagnostics;
|
|
1134
|
-
this.#options = Options.for(
|
|
1158
|
+
this.#options = Options.for(OptionGroup.CommandLine);
|
|
1135
1159
|
}
|
|
1136
1160
|
async #onExpectsValue(optionName, optionBrand) {
|
|
1137
1161
|
const text = [
|
|
@@ -1166,18 +1190,18 @@ class CommandLineParser {
|
|
|
1166
1190
|
async #parseOptionValue(commandLineArgs, index, optionName, optionDefinition) {
|
|
1167
1191
|
let optionValue = this.#resolveOptionValue(commandLineArgs[index]);
|
|
1168
1192
|
switch (optionDefinition.brand) {
|
|
1169
|
-
case
|
|
1193
|
+
case OptionBrand.BareTrue:
|
|
1170
1194
|
await Options.validate(optionName, optionValue, optionDefinition.brand, this.#onDiagnostics);
|
|
1171
1195
|
this.#commandLineOptions[optionDefinition.name] = true;
|
|
1172
1196
|
break;
|
|
1173
|
-
case
|
|
1197
|
+
case OptionBrand.Boolean:
|
|
1174
1198
|
await Options.validate(optionName, optionValue, optionDefinition.brand, this.#onDiagnostics);
|
|
1175
1199
|
this.#commandLineOptions[optionDefinition.name] = optionValue !== "false";
|
|
1176
1200
|
if (optionValue === "false" || optionValue === "true") {
|
|
1177
1201
|
index++;
|
|
1178
1202
|
}
|
|
1179
1203
|
break;
|
|
1180
|
-
case
|
|
1204
|
+
case OptionBrand.List:
|
|
1181
1205
|
if (optionValue !== "") {
|
|
1182
1206
|
const optionValues = optionValue
|
|
1183
1207
|
.split(",")
|
|
@@ -1193,7 +1217,7 @@ class CommandLineParser {
|
|
|
1193
1217
|
}
|
|
1194
1218
|
await this.#onExpectsValue(optionName, optionDefinition.brand);
|
|
1195
1219
|
break;
|
|
1196
|
-
case
|
|
1220
|
+
case OptionBrand.String:
|
|
1197
1221
|
if (optionValue !== "") {
|
|
1198
1222
|
optionValue = Options.resolve(optionName, optionValue);
|
|
1199
1223
|
await Options.validate(optionName, optionValue, optionDefinition.brand, this.#onDiagnostics);
|
|
@@ -1349,7 +1373,7 @@ class ConfigFileParser {
|
|
|
1349
1373
|
this.#configFileOptions = configFileOptions;
|
|
1350
1374
|
this.#sourceFile = sourceFile;
|
|
1351
1375
|
this.#onDiagnostics = onDiagnostics;
|
|
1352
|
-
this.#options = Options.for(
|
|
1376
|
+
this.#options = Options.for(OptionGroup.ConfigFile);
|
|
1353
1377
|
this.#jsonScanner = new JsonScanner(this.#sourceFile);
|
|
1354
1378
|
}
|
|
1355
1379
|
#onRequiresValue(optionDefinition, jsonNode, isListItem) {
|
|
@@ -1362,7 +1386,7 @@ class ConfigFileParser {
|
|
|
1362
1386
|
let jsonNode;
|
|
1363
1387
|
let optionValue;
|
|
1364
1388
|
switch (optionDefinition.brand) {
|
|
1365
|
-
case
|
|
1389
|
+
case OptionBrand.Boolean: {
|
|
1366
1390
|
jsonNode = this.#jsonScanner.read();
|
|
1367
1391
|
optionValue = jsonNode.getValue();
|
|
1368
1392
|
if (typeof optionValue !== "boolean") {
|
|
@@ -1371,7 +1395,7 @@ class ConfigFileParser {
|
|
|
1371
1395
|
}
|
|
1372
1396
|
break;
|
|
1373
1397
|
}
|
|
1374
|
-
case
|
|
1398
|
+
case OptionBrand.String: {
|
|
1375
1399
|
jsonNode = this.#jsonScanner.read();
|
|
1376
1400
|
optionValue = jsonNode.getValue();
|
|
1377
1401
|
if (typeof optionValue !== "string") {
|
|
@@ -1383,7 +1407,7 @@ class ConfigFileParser {
|
|
|
1383
1407
|
await Options.validate(optionDefinition.name, optionValue, optionDefinition.brand, this.#onDiagnostics, jsonNode.origin);
|
|
1384
1408
|
break;
|
|
1385
1409
|
}
|
|
1386
|
-
case
|
|
1410
|
+
case OptionBrand.List: {
|
|
1387
1411
|
optionValue = [];
|
|
1388
1412
|
const leftBracketToken = this.#jsonScanner.readToken("[");
|
|
1389
1413
|
if (!leftBracketToken.text) {
|
|
@@ -1542,22 +1566,6 @@ class Config {
|
|
|
1542
1566
|
}
|
|
1543
1567
|
}
|
|
1544
1568
|
|
|
1545
|
-
var OptionBrand;
|
|
1546
|
-
(function (OptionBrand) {
|
|
1547
|
-
OptionBrand["String"] = "string";
|
|
1548
|
-
OptionBrand["Number"] = "number";
|
|
1549
|
-
OptionBrand["Boolean"] = "boolean";
|
|
1550
|
-
OptionBrand["BareTrue"] = "bareTrue";
|
|
1551
|
-
OptionBrand["List"] = "list";
|
|
1552
|
-
})(OptionBrand || (OptionBrand = {}));
|
|
1553
|
-
|
|
1554
|
-
var OptionGroup;
|
|
1555
|
-
(function (OptionGroup) {
|
|
1556
|
-
OptionGroup[OptionGroup["CommandLine"] = 2] = "CommandLine";
|
|
1557
|
-
OptionGroup[OptionGroup["ConfigFile"] = 4] = "ConfigFile";
|
|
1558
|
-
OptionGroup[OptionGroup["ResolvedConfig"] = 6] = "ResolvedConfig";
|
|
1559
|
-
})(OptionGroup || (OptionGroup = {}));
|
|
1560
|
-
|
|
1561
1569
|
class CancellationHandler {
|
|
1562
1570
|
#cancellationToken;
|
|
1563
1571
|
#cancellationReason;
|
|
@@ -1567,7 +1575,7 @@ class CancellationHandler {
|
|
|
1567
1575
|
}
|
|
1568
1576
|
on([, payload]) {
|
|
1569
1577
|
if ("diagnostics" in payload) {
|
|
1570
|
-
if (payload.diagnostics.some((diagnostic) => diagnostic.category ===
|
|
1578
|
+
if (payload.diagnostics.some((diagnostic) => diagnostic.category === DiagnosticCategory.Error)) {
|
|
1571
1579
|
this.#cancellationToken.cancel(this.#cancellationReason);
|
|
1572
1580
|
}
|
|
1573
1581
|
}
|
|
@@ -1581,7 +1589,7 @@ class ExitCodeHandler {
|
|
|
1581
1589
|
return;
|
|
1582
1590
|
}
|
|
1583
1591
|
if ("diagnostics" in payload) {
|
|
1584
|
-
if (payload.diagnostics.some((diagnostic) => diagnostic.category ===
|
|
1592
|
+
if (payload.diagnostics.some((diagnostic) => diagnostic.category === DiagnosticCategory.Error)) {
|
|
1585
1593
|
this.#setCode(1);
|
|
1586
1594
|
}
|
|
1587
1595
|
}
|
|
@@ -1613,11 +1621,20 @@ class DescribeResult {
|
|
|
1613
1621
|
}
|
|
1614
1622
|
}
|
|
1615
1623
|
|
|
1624
|
+
var ResultStatus;
|
|
1625
|
+
(function (ResultStatus) {
|
|
1626
|
+
ResultStatus["Runs"] = "runs";
|
|
1627
|
+
ResultStatus["Passed"] = "passed";
|
|
1628
|
+
ResultStatus["Failed"] = "failed";
|
|
1629
|
+
ResultStatus["Skipped"] = "skipped";
|
|
1630
|
+
ResultStatus["Todo"] = "todo";
|
|
1631
|
+
})(ResultStatus || (ResultStatus = {}));
|
|
1632
|
+
|
|
1616
1633
|
class ExpectResult {
|
|
1617
1634
|
assertion;
|
|
1618
1635
|
diagnostics = [];
|
|
1619
1636
|
parent;
|
|
1620
|
-
status =
|
|
1637
|
+
status = ResultStatus.Runs;
|
|
1621
1638
|
timing = new ResultTiming();
|
|
1622
1639
|
constructor(assertion, parent) {
|
|
1623
1640
|
this.assertion = assertion;
|
|
@@ -1661,18 +1678,9 @@ class Result {
|
|
|
1661
1678
|
}
|
|
1662
1679
|
}
|
|
1663
1680
|
|
|
1664
|
-
var ResultStatus;
|
|
1665
|
-
(function (ResultStatus) {
|
|
1666
|
-
ResultStatus["Runs"] = "runs";
|
|
1667
|
-
ResultStatus["Passed"] = "passed";
|
|
1668
|
-
ResultStatus["Failed"] = "failed";
|
|
1669
|
-
ResultStatus["Skipped"] = "skipped";
|
|
1670
|
-
ResultStatus["Todo"] = "todo";
|
|
1671
|
-
})(ResultStatus || (ResultStatus = {}));
|
|
1672
|
-
|
|
1673
1681
|
class TargetResult {
|
|
1674
1682
|
results = new Map();
|
|
1675
|
-
status =
|
|
1683
|
+
status = ResultStatus.Runs;
|
|
1676
1684
|
target;
|
|
1677
1685
|
tasks;
|
|
1678
1686
|
timing = new ResultTiming();
|
|
@@ -1686,7 +1694,7 @@ class TaskResult {
|
|
|
1686
1694
|
diagnostics = [];
|
|
1687
1695
|
expectCount = new ResultCount();
|
|
1688
1696
|
results = [];
|
|
1689
|
-
status =
|
|
1697
|
+
status = ResultStatus.Runs;
|
|
1690
1698
|
task;
|
|
1691
1699
|
testCount = new ResultCount();
|
|
1692
1700
|
timing = new ResultTiming();
|
|
@@ -1700,7 +1708,7 @@ class TestResult {
|
|
|
1700
1708
|
expectCount = new ResultCount();
|
|
1701
1709
|
parent;
|
|
1702
1710
|
results = [];
|
|
1703
|
-
status =
|
|
1711
|
+
status = ResultStatus.Runs;
|
|
1704
1712
|
test;
|
|
1705
1713
|
timing = new ResultTiming();
|
|
1706
1714
|
constructor(test, parent) {
|
|
@@ -1733,19 +1741,19 @@ class ResultHandler {
|
|
|
1733
1741
|
this.#targetResult.timing.start = Date.now();
|
|
1734
1742
|
break;
|
|
1735
1743
|
case "target:end":
|
|
1736
|
-
if (this.#targetResult.status ===
|
|
1744
|
+
if (this.#targetResult.status === ResultStatus.Failed) {
|
|
1737
1745
|
this.#result.targetCount.failed++;
|
|
1738
1746
|
}
|
|
1739
1747
|
else {
|
|
1740
1748
|
this.#result.targetCount.passed++;
|
|
1741
|
-
this.#targetResult.status =
|
|
1749
|
+
this.#targetResult.status = ResultStatus.Passed;
|
|
1742
1750
|
}
|
|
1743
1751
|
this.#targetResult.timing.end = Date.now();
|
|
1744
1752
|
this.#targetResult = undefined;
|
|
1745
1753
|
break;
|
|
1746
1754
|
case "store:error":
|
|
1747
|
-
if (payload.diagnostics.some(({ category }) => category ===
|
|
1748
|
-
this.#targetResult.status =
|
|
1755
|
+
if (payload.diagnostics.some(({ category }) => category === DiagnosticCategory.Error)) {
|
|
1756
|
+
this.#targetResult.status = ResultStatus.Failed;
|
|
1749
1757
|
}
|
|
1750
1758
|
break;
|
|
1751
1759
|
case "project:uses": {
|
|
@@ -1758,7 +1766,7 @@ class ResultHandler {
|
|
|
1758
1766
|
break;
|
|
1759
1767
|
}
|
|
1760
1768
|
case "project:error":
|
|
1761
|
-
this.#targetResult.status =
|
|
1769
|
+
this.#targetResult.status = ResultStatus.Failed;
|
|
1762
1770
|
this.#projectResult.diagnostics.push(...payload.diagnostics);
|
|
1763
1771
|
break;
|
|
1764
1772
|
case "task:start":
|
|
@@ -1767,21 +1775,21 @@ class ResultHandler {
|
|
|
1767
1775
|
this.#taskResult.timing.start = Date.now();
|
|
1768
1776
|
break;
|
|
1769
1777
|
case "task:error":
|
|
1770
|
-
this.#targetResult.status =
|
|
1771
|
-
this.#taskResult.status =
|
|
1778
|
+
this.#targetResult.status = ResultStatus.Failed;
|
|
1779
|
+
this.#taskResult.status = ResultStatus.Failed;
|
|
1772
1780
|
this.#taskResult.diagnostics.push(...payload.diagnostics);
|
|
1773
1781
|
break;
|
|
1774
1782
|
case "task:end":
|
|
1775
|
-
if (this.#taskResult.status ===
|
|
1783
|
+
if (this.#taskResult.status === ResultStatus.Failed ||
|
|
1776
1784
|
this.#taskResult.expectCount.failed > 0 ||
|
|
1777
1785
|
this.#taskResult.testCount.failed > 0) {
|
|
1778
1786
|
this.#result.fileCount.failed++;
|
|
1779
|
-
this.#targetResult.status =
|
|
1780
|
-
this.#taskResult.status =
|
|
1787
|
+
this.#targetResult.status = ResultStatus.Failed;
|
|
1788
|
+
this.#taskResult.status = ResultStatus.Failed;
|
|
1781
1789
|
}
|
|
1782
1790
|
else {
|
|
1783
1791
|
this.#result.fileCount.passed++;
|
|
1784
|
-
this.#taskResult.status =
|
|
1792
|
+
this.#taskResult.status = ResultStatus.Passed;
|
|
1785
1793
|
}
|
|
1786
1794
|
this.#taskResult.timing.end = Date.now();
|
|
1787
1795
|
this.#taskResult = undefined;
|
|
@@ -1813,7 +1821,7 @@ class ResultHandler {
|
|
|
1813
1821
|
case "test:error":
|
|
1814
1822
|
this.#result.testCount.failed++;
|
|
1815
1823
|
this.#taskResult.testCount.failed++;
|
|
1816
|
-
this.#testResult.status =
|
|
1824
|
+
this.#testResult.status = ResultStatus.Failed;
|
|
1817
1825
|
this.#testResult.diagnostics.push(...payload.diagnostics);
|
|
1818
1826
|
this.#testResult.timing.end = Date.now();
|
|
1819
1827
|
this.#testResult = undefined;
|
|
@@ -1821,28 +1829,28 @@ class ResultHandler {
|
|
|
1821
1829
|
case "test:fail":
|
|
1822
1830
|
this.#result.testCount.failed++;
|
|
1823
1831
|
this.#taskResult.testCount.failed++;
|
|
1824
|
-
this.#testResult.status =
|
|
1832
|
+
this.#testResult.status = ResultStatus.Failed;
|
|
1825
1833
|
this.#testResult.timing.end = Date.now();
|
|
1826
1834
|
this.#testResult = undefined;
|
|
1827
1835
|
break;
|
|
1828
1836
|
case "test:pass":
|
|
1829
1837
|
this.#result.testCount.passed++;
|
|
1830
1838
|
this.#taskResult.testCount.passed++;
|
|
1831
|
-
this.#testResult.status =
|
|
1839
|
+
this.#testResult.status = ResultStatus.Passed;
|
|
1832
1840
|
this.#testResult.timing.end = Date.now();
|
|
1833
1841
|
this.#testResult = undefined;
|
|
1834
1842
|
break;
|
|
1835
1843
|
case "test:skip":
|
|
1836
1844
|
this.#result.testCount.skipped++;
|
|
1837
1845
|
this.#taskResult.testCount.skipped++;
|
|
1838
|
-
this.#testResult.status =
|
|
1846
|
+
this.#testResult.status = ResultStatus.Skipped;
|
|
1839
1847
|
this.#testResult.timing.end = Date.now();
|
|
1840
1848
|
this.#testResult = undefined;
|
|
1841
1849
|
break;
|
|
1842
1850
|
case "test:todo":
|
|
1843
1851
|
this.#result.testCount.todo++;
|
|
1844
1852
|
this.#taskResult.testCount.todo++;
|
|
1845
|
-
this.#testResult.status =
|
|
1853
|
+
this.#testResult.status = ResultStatus.Todo;
|
|
1846
1854
|
this.#testResult.timing.end = Date.now();
|
|
1847
1855
|
this.#testResult = undefined;
|
|
1848
1856
|
break;
|
|
@@ -1862,7 +1870,7 @@ class ResultHandler {
|
|
|
1862
1870
|
if (this.#testResult) {
|
|
1863
1871
|
this.#testResult.expectCount.failed++;
|
|
1864
1872
|
}
|
|
1865
|
-
this.#expectResult.status =
|
|
1873
|
+
this.#expectResult.status = ResultStatus.Failed;
|
|
1866
1874
|
this.#expectResult.diagnostics.push(...payload.diagnostics);
|
|
1867
1875
|
this.#expectResult.timing.end = Date.now();
|
|
1868
1876
|
this.#expectResult = undefined;
|
|
@@ -1873,7 +1881,7 @@ class ResultHandler {
|
|
|
1873
1881
|
if (this.#testResult) {
|
|
1874
1882
|
this.#testResult.expectCount.failed++;
|
|
1875
1883
|
}
|
|
1876
|
-
this.#expectResult.status =
|
|
1884
|
+
this.#expectResult.status = ResultStatus.Failed;
|
|
1877
1885
|
this.#expectResult.timing.end = Date.now();
|
|
1878
1886
|
this.#expectResult = undefined;
|
|
1879
1887
|
break;
|
|
@@ -1883,7 +1891,7 @@ class ResultHandler {
|
|
|
1883
1891
|
if (this.#testResult) {
|
|
1884
1892
|
this.#testResult.expectCount.passed++;
|
|
1885
1893
|
}
|
|
1886
|
-
this.#expectResult.status =
|
|
1894
|
+
this.#expectResult.status = ResultStatus.Passed;
|
|
1887
1895
|
this.#expectResult.timing.end = Date.now();
|
|
1888
1896
|
this.#expectResult = undefined;
|
|
1889
1897
|
break;
|
|
@@ -1893,7 +1901,7 @@ class ResultHandler {
|
|
|
1893
1901
|
if (this.#testResult) {
|
|
1894
1902
|
this.#testResult.expectCount.skipped++;
|
|
1895
1903
|
}
|
|
1896
|
-
this.#expectResult.status =
|
|
1904
|
+
this.#expectResult.status = ResultStatus.Skipped;
|
|
1897
1905
|
this.#expectResult.timing.end = Date.now();
|
|
1898
1906
|
this.#expectResult = undefined;
|
|
1899
1907
|
break;
|
|
@@ -1922,7 +1930,7 @@ function Text({ children, color, indent }) {
|
|
|
1922
1930
|
if (color != null) {
|
|
1923
1931
|
ansiEscapes.push(color);
|
|
1924
1932
|
}
|
|
1925
|
-
return (jsx("text", { indent: indent ?? 0, children: [ansiEscapes.length > 0 ? jsx("ansi", { escapes: ansiEscapes }) : undefined, children, ansiEscapes.length > 0 ? jsx("ansi", { escapes:
|
|
1933
|
+
return (jsx("text", { indent: indent ?? 0, children: [ansiEscapes.length > 0 ? jsx("ansi", { escapes: ansiEscapes }) : undefined, children, ansiEscapes.length > 0 ? jsx("ansi", { escapes: Color.Reset }) : undefined] }));
|
|
1926
1934
|
}
|
|
1927
1935
|
|
|
1928
1936
|
function Line({ children, color, indent }) {
|
|
@@ -1983,7 +1991,7 @@ class Scribbler {
|
|
|
1983
1991
|
}
|
|
1984
1992
|
|
|
1985
1993
|
function addsPackageText(packageVersion, packagePath) {
|
|
1986
|
-
return (jsx(Line, { children: [jsx(Text, { color:
|
|
1994
|
+
return (jsx(Line, { children: [jsx(Text, { color: Color.Gray, children: "adds" }), " TypeScript ", packageVersion, jsx(Text, { color: Color.Gray, children: [" to ", packagePath] })] }));
|
|
1987
1995
|
}
|
|
1988
1996
|
|
|
1989
1997
|
function describeNameText(name, indent = 0) {
|
|
@@ -1997,13 +2005,13 @@ function BreadcrumbsText({ ancestor }) {
|
|
|
1997
2005
|
ancestor = ancestor.parent;
|
|
1998
2006
|
}
|
|
1999
2007
|
text.push("");
|
|
2000
|
-
return jsx(Text, { color:
|
|
2008
|
+
return jsx(Text, { color: Color.Gray, children: text.reverse().join(" ❭ ") });
|
|
2001
2009
|
}
|
|
2002
|
-
function CodeLineText({ gutterWidth, lineNumber, lineNumberColor =
|
|
2003
|
-
return (jsx(Line, { children: [jsx(Text, { color: lineNumberColor, children: lineNumber.toString().padStart(gutterWidth) }), jsx(Text, { color:
|
|
2010
|
+
function CodeLineText({ gutterWidth, lineNumber, lineNumberColor = Color.Gray, lineText }) {
|
|
2011
|
+
return (jsx(Line, { children: [jsx(Text, { color: lineNumberColor, children: lineNumber.toString().padStart(gutterWidth) }), jsx(Text, { color: Color.Gray, children: " | " }), lineText] }));
|
|
2004
2012
|
}
|
|
2005
2013
|
function SquiggleLineText({ gutterWidth, indentWidth = 0, squiggleColor, squiggleWidth }) {
|
|
2006
|
-
return (jsx(Line, { children: [" ".repeat(gutterWidth), jsx(Text, { color:
|
|
2014
|
+
return (jsx(Line, { children: [" ".repeat(gutterWidth), jsx(Text, { color: Color.Gray, children: " | " }), " ".repeat(indentWidth), jsx(Text, { color: squiggleColor, children: "~".repeat(squiggleWidth === 0 ? 1 : squiggleWidth) })] }));
|
|
2007
2015
|
}
|
|
2008
2016
|
function CodeSpanText({ diagnosticCategory, diagnosticOrigin }) {
|
|
2009
2017
|
const lineMap = diagnosticOrigin.sourceFile.getLineStarts();
|
|
@@ -2014,11 +2022,11 @@ function CodeSpanText({ diagnosticCategory, diagnosticOrigin }) {
|
|
|
2014
2022
|
const gutterWidth = (lastLine + 1).toString().length + 2;
|
|
2015
2023
|
let highlightColor;
|
|
2016
2024
|
switch (diagnosticCategory) {
|
|
2017
|
-
case
|
|
2018
|
-
highlightColor =
|
|
2025
|
+
case DiagnosticCategory.Error:
|
|
2026
|
+
highlightColor = Color.Red;
|
|
2019
2027
|
break;
|
|
2020
|
-
case
|
|
2021
|
-
highlightColor =
|
|
2028
|
+
case DiagnosticCategory.Warning:
|
|
2029
|
+
highlightColor = Color.Yellow;
|
|
2022
2030
|
break;
|
|
2023
2031
|
}
|
|
2024
2032
|
const codeSpan = [];
|
|
@@ -2045,14 +2053,14 @@ function CodeSpanText({ diagnosticCategory, diagnosticOrigin }) {
|
|
|
2045
2053
|
codeSpan.push(jsx(CodeLineText, { gutterWidth: gutterWidth, lineNumber: index + 1, lineText: lineText }));
|
|
2046
2054
|
}
|
|
2047
2055
|
}
|
|
2048
|
-
const location = (jsx(Line, { children: [" ".repeat(gutterWidth + 2), jsx(Text, { color:
|
|
2056
|
+
const location = (jsx(Line, { children: [" ".repeat(gutterWidth + 2), jsx(Text, { color: Color.Gray, children: " at " }), jsx(Text, { color: Color.Cyan, children: Path.relative("", diagnosticOrigin.sourceFile.fileName) }), jsx(Text, { color: Color.Gray, children: `:${firstMarkedLine + 1}:${firstMarkedLineCharacter + 1}` }), diagnosticOrigin.assertion && jsx(BreadcrumbsText, { ancestor: diagnosticOrigin.assertion.parent })] }));
|
|
2049
2057
|
return (jsx(Text, { children: [codeSpan, jsx(Line, {}), location] }));
|
|
2050
2058
|
}
|
|
2051
2059
|
|
|
2052
2060
|
function DiagnosticText({ diagnostic }) {
|
|
2053
|
-
const code = diagnostic.code ? jsx(Text, { color:
|
|
2061
|
+
const code = diagnostic.code ? jsx(Text, { color: Color.Gray, children: [" ", diagnostic.code] }) : undefined;
|
|
2054
2062
|
const text = Array.isArray(diagnostic.text) ? diagnostic.text : [diagnostic.text];
|
|
2055
|
-
const message = text.map((text, index) => (jsx(Text, { children: [index === 1 ? jsx(Line, {}) : undefined, jsx(Line, { children: [text, code] })] })));
|
|
2063
|
+
const message = text.map((text, index) => (jsx(Text, { children: [index === 1 ? jsx(Line, {}) : undefined, jsx(Line, { children: [text, index === 0 ? code : undefined] })] })));
|
|
2056
2064
|
const related = diagnostic.related?.map((relatedDiagnostic) => jsx(DiagnosticText, { diagnostic: relatedDiagnostic }));
|
|
2057
2065
|
const codeSpan = diagnostic.origin ? (jsx(Text, { children: [jsx(Line, {}), jsx(CodeSpanText, { diagnosticCategory: diagnostic.category, diagnosticOrigin: diagnostic.origin })] })) : undefined;
|
|
2058
2066
|
return (jsx(Text, { children: [message, codeSpan, jsx(Line, {}), jsx(Text, { indent: 2, children: related })] }));
|
|
@@ -2060,11 +2068,11 @@ function DiagnosticText({ diagnostic }) {
|
|
|
2060
2068
|
function diagnosticText(diagnostic) {
|
|
2061
2069
|
let prefix;
|
|
2062
2070
|
switch (diagnostic.category) {
|
|
2063
|
-
case
|
|
2064
|
-
prefix = jsx(Text, { color:
|
|
2071
|
+
case DiagnosticCategory.Error:
|
|
2072
|
+
prefix = jsx(Text, { color: Color.Red, children: "Error: " });
|
|
2065
2073
|
break;
|
|
2066
|
-
case
|
|
2067
|
-
prefix = jsx(Text, { color:
|
|
2074
|
+
case DiagnosticCategory.Warning:
|
|
2075
|
+
prefix = jsx(Text, { color: Color.Yellow, children: "Warning: " });
|
|
2068
2076
|
break;
|
|
2069
2077
|
}
|
|
2070
2078
|
return (jsx(Text, { children: [prefix, jsx(DiagnosticText, { diagnostic: diagnostic })] }));
|
|
@@ -2075,22 +2083,22 @@ function FileNameText({ filePath }) {
|
|
|
2075
2083
|
const lastPathSeparator = relativePath.lastIndexOf("/");
|
|
2076
2084
|
const directoryNameText = relativePath.slice(0, lastPathSeparator + 1);
|
|
2077
2085
|
const fileNameText = relativePath.slice(lastPathSeparator + 1);
|
|
2078
|
-
return (jsx(Text, { children: [jsx(Text, { color:
|
|
2086
|
+
return (jsx(Text, { children: [jsx(Text, { color: Color.Gray, children: directoryNameText }), fileNameText] }));
|
|
2079
2087
|
}
|
|
2080
2088
|
function taskStatusText(status, task) {
|
|
2081
2089
|
let statusColor;
|
|
2082
2090
|
let statusText;
|
|
2083
2091
|
switch (status) {
|
|
2084
|
-
case
|
|
2085
|
-
statusColor =
|
|
2092
|
+
case ResultStatus.Runs:
|
|
2093
|
+
statusColor = Color.Yellow;
|
|
2086
2094
|
statusText = "runs";
|
|
2087
2095
|
break;
|
|
2088
|
-
case
|
|
2089
|
-
statusColor =
|
|
2096
|
+
case ResultStatus.Passed:
|
|
2097
|
+
statusColor = Color.Green;
|
|
2090
2098
|
statusText = "pass";
|
|
2091
2099
|
break;
|
|
2092
|
-
case
|
|
2093
|
-
statusColor =
|
|
2100
|
+
case ResultStatus.Failed:
|
|
2101
|
+
statusColor = Color.Red;
|
|
2094
2102
|
statusText = "fail";
|
|
2095
2103
|
break;
|
|
2096
2104
|
}
|
|
@@ -2120,13 +2128,13 @@ function formattedText(input) {
|
|
|
2120
2128
|
}
|
|
2121
2129
|
|
|
2122
2130
|
function HintText({ children }) {
|
|
2123
|
-
return (jsx(Text, { indent: 1, color:
|
|
2131
|
+
return (jsx(Text, { indent: 1, color: Color.Gray, children: children }));
|
|
2124
2132
|
}
|
|
2125
2133
|
function HelpHeaderText({ tstycheVersion }) {
|
|
2126
2134
|
return (jsx(Line, { children: ["The TSTyche Type Test Runner", jsx(HintText, { children: tstycheVersion })] }));
|
|
2127
2135
|
}
|
|
2128
2136
|
function CommandText({ hint, text }) {
|
|
2129
|
-
return (jsx(Line, { indent: 1, children: [jsx(Text, { color:
|
|
2137
|
+
return (jsx(Line, { indent: 1, children: [jsx(Text, { color: Color.Blue, children: text }), hint && jsx(HintText, { children: hint })] }));
|
|
2130
2138
|
}
|
|
2131
2139
|
function OptionDescriptionText({ text }) {
|
|
2132
2140
|
return jsx(Line, { indent: 1, children: text });
|
|
@@ -2144,7 +2152,7 @@ function CommandLineOptionNameText({ text }) {
|
|
|
2144
2152
|
return jsx(Text, { children: `--${text}` });
|
|
2145
2153
|
}
|
|
2146
2154
|
function CommandLineOptionHintText({ definition }) {
|
|
2147
|
-
if (definition.brand ===
|
|
2155
|
+
if (definition.brand === OptionBrand.List) {
|
|
2148
2156
|
return jsx(Text, { children: `${definition.brand} of ${definition.items.brand}s` });
|
|
2149
2157
|
}
|
|
2150
2158
|
return jsx(Text, { children: definition.brand });
|
|
@@ -2153,7 +2161,7 @@ function CommandLineOptionsText({ optionDefinitions }) {
|
|
|
2153
2161
|
const definitions = [...optionDefinitions.values()];
|
|
2154
2162
|
const optionsText = definitions.map((definition) => {
|
|
2155
2163
|
let hint;
|
|
2156
|
-
if (definition.brand !==
|
|
2164
|
+
if (definition.brand !== OptionBrand.BareTrue) {
|
|
2157
2165
|
hint = jsx(CommandLineOptionHintText, { definition: definition });
|
|
2158
2166
|
}
|
|
2159
2167
|
return (jsx(Text, { children: [jsx(CommandText, { text: jsx(CommandLineOptionNameText, { text: definition.name }), hint: hint }), jsx(OptionDescriptionText, { text: definition.description }), jsx(Line, {})] }));
|
|
@@ -2203,7 +2211,7 @@ function RowText({ label, text }) {
|
|
|
2203
2211
|
return (jsx(Line, { children: [`${label}:`.padEnd(12), text] }));
|
|
2204
2212
|
}
|
|
2205
2213
|
function CountText({ failed, passed, skipped, todo, total }) {
|
|
2206
|
-
return (jsx(Text, { children: [failed > 0 ? (jsx(Text, { children: [jsx(Text, { color:
|
|
2214
|
+
return (jsx(Text, { children: [failed > 0 ? (jsx(Text, { children: [jsx(Text, { color: Color.Red, children: [failed, " failed"] }), jsx(Text, { children: ", " })] })) : undefined, skipped > 0 ? (jsx(Text, { children: [jsx(Text, { color: Color.Yellow, children: [skipped, " skipped"] }), jsx(Text, { children: ", " })] })) : undefined, todo > 0 ? (jsx(Text, { children: [jsx(Text, { color: Color.Magenta, children: [todo, " todo"] }), jsx(Text, { children: ", " })] })) : undefined, passed > 0 ? (jsx(Text, { children: [jsx(Text, { color: Color.Green, children: [passed, " passed"] }), jsx(Text, { children: ", " })] })) : undefined, jsx(Text, { children: [total, " total"] })] }));
|
|
2207
2215
|
}
|
|
2208
2216
|
function DurationText({ seconds }) {
|
|
2209
2217
|
return jsx(Text, { children: `${Math.round(seconds * 10) / 10}s` });
|
|
@@ -2216,24 +2224,24 @@ function MatchText({ text }) {
|
|
|
2216
2224
|
return jsx(Text, { children: ["'", ...text, "'"] });
|
|
2217
2225
|
}
|
|
2218
2226
|
const lastItem = text.pop();
|
|
2219
|
-
return (jsx(Text, { children: [text.map((match, index, list) => (jsx(Text, { children: ["'", match, "'", index === list.length - 1 ? jsx(Text, { children: " " }) : jsx(Text, { color:
|
|
2227
|
+
return (jsx(Text, { children: [text.map((match, index, list) => (jsx(Text, { children: ["'", match, "'", index === list.length - 1 ? jsx(Text, { children: " " }) : jsx(Text, { color: Color.Gray, children: ", " })] }))), jsx(Text, { color: Color.Gray, children: "or" }), " '", lastItem, "'"] }));
|
|
2220
2228
|
}
|
|
2221
2229
|
function RanFilesText({ onlyMatch, pathMatch, skipMatch }) {
|
|
2222
2230
|
const testNameMatchText = [];
|
|
2223
2231
|
if (onlyMatch != null) {
|
|
2224
|
-
testNameMatchText.push(jsx(Text, { children: [jsx(Text, { color:
|
|
2232
|
+
testNameMatchText.push(jsx(Text, { children: [jsx(Text, { color: Color.Gray, children: "matching " }), jsx(MatchText, { text: onlyMatch })] }));
|
|
2225
2233
|
}
|
|
2226
2234
|
if (skipMatch != null) {
|
|
2227
|
-
testNameMatchText.push(jsx(Text, { children: [onlyMatch && jsx(Text, { color:
|
|
2235
|
+
testNameMatchText.push(jsx(Text, { children: [onlyMatch && jsx(Text, { color: Color.Gray, children: " and " }), jsx(Text, { color: Color.Gray, children: "not matching " }), jsx(MatchText, { text: skipMatch })] }));
|
|
2228
2236
|
}
|
|
2229
2237
|
let pathMatchText;
|
|
2230
2238
|
if (pathMatch.length > 0) {
|
|
2231
|
-
pathMatchText = (jsx(Text, { children: [jsx(Text, { color:
|
|
2239
|
+
pathMatchText = (jsx(Text, { children: [jsx(Text, { color: Color.Gray, children: "test files matching " }), jsx(MatchText, { text: pathMatch }), jsx(Text, { color: Color.Gray, children: "." })] }));
|
|
2232
2240
|
}
|
|
2233
2241
|
else {
|
|
2234
|
-
pathMatchText = jsx(Text, { color:
|
|
2242
|
+
pathMatchText = jsx(Text, { color: Color.Gray, children: "all test files." });
|
|
2235
2243
|
}
|
|
2236
|
-
return (jsx(Line, { children: [jsx(Text, { color:
|
|
2244
|
+
return (jsx(Line, { children: [jsx(Text, { color: Color.Gray, children: "Ran " }), testNameMatchText.length > 0 ? jsx(Text, { color: Color.Gray, children: "tests " }) : undefined, testNameMatchText, testNameMatchText.length > 0 ? jsx(Text, { color: Color.Gray, children: " in " }) : undefined, pathMatchText] }));
|
|
2237
2245
|
}
|
|
2238
2246
|
function summaryText({ duration, expectCount, fileCount, onlyMatch, pathMatch, skipMatch, targetCount, testCount, }) {
|
|
2239
2247
|
const targetCountText = (jsx(RowText, { label: "Targets", text: jsx(CountText, { failed: targetCount.failed, passed: targetCount.passed, skipped: targetCount.skipped, todo: targetCount.todo, total: targetCount.total }) }));
|
|
@@ -2246,25 +2254,25 @@ function summaryText({ duration, expectCount, fileCount, onlyMatch, pathMatch, s
|
|
|
2246
2254
|
function StatusText({ status }) {
|
|
2247
2255
|
switch (status) {
|
|
2248
2256
|
case "fail":
|
|
2249
|
-
return jsx(Text, { color:
|
|
2257
|
+
return jsx(Text, { color: Color.Red, children: "\u00D7" });
|
|
2250
2258
|
case "pass":
|
|
2251
|
-
return jsx(Text, { color:
|
|
2259
|
+
return jsx(Text, { color: Color.Green, children: "+" });
|
|
2252
2260
|
case "skip":
|
|
2253
|
-
return jsx(Text, { color:
|
|
2261
|
+
return jsx(Text, { color: Color.Yellow, children: "- skip" });
|
|
2254
2262
|
case "todo":
|
|
2255
|
-
return jsx(Text, { color:
|
|
2263
|
+
return jsx(Text, { color: Color.Magenta, children: "- todo" });
|
|
2256
2264
|
}
|
|
2257
2265
|
}
|
|
2258
2266
|
function testNameText(status, name, indent = 0) {
|
|
2259
|
-
return (jsx(Line, { indent: indent + 1, children: [jsx(StatusText, { status: status }), " ", jsx(Text, { color:
|
|
2267
|
+
return (jsx(Line, { indent: indent + 1, children: [jsx(StatusText, { status: status }), " ", jsx(Text, { color: Color.Gray, children: name })] }));
|
|
2260
2268
|
}
|
|
2261
2269
|
|
|
2262
2270
|
function usesCompilerText(compilerVersion, projectConfigFilePath, options) {
|
|
2263
2271
|
let projectConfigPathText;
|
|
2264
2272
|
if (projectConfigFilePath != null) {
|
|
2265
|
-
projectConfigPathText = (jsx(Text, { color:
|
|
2273
|
+
projectConfigPathText = (jsx(Text, { color: Color.Gray, children: [" with ", Path.relative("", projectConfigFilePath)] }));
|
|
2266
2274
|
}
|
|
2267
|
-
return (jsx(Text, { children: [options?.prependEmptyLine ? jsx(Line, {}) : undefined, jsx(Line, { children: [jsx(Text, { color:
|
|
2275
|
+
return (jsx(Text, { children: [options?.prependEmptyLine ? jsx(Line, {}) : undefined, jsx(Line, { children: [jsx(Text, { color: Color.Blue, children: "uses" }), " TypeScript ", compilerVersion, projectConfigPathText] }), jsx(Line, {})] }));
|
|
2268
2276
|
}
|
|
2269
2277
|
|
|
2270
2278
|
function waitingForFileChangesText() {
|
|
@@ -2277,7 +2285,7 @@ function watchUsageText() {
|
|
|
2277
2285
|
["x", "to exit."],
|
|
2278
2286
|
];
|
|
2279
2287
|
const usageText = usage.map(([keyText, actionText]) => {
|
|
2280
|
-
return (jsx(Line, { children: [jsx(Text, { color:
|
|
2288
|
+
return (jsx(Line, { children: [jsx(Text, { color: Color.Gray, children: "Press" }), jsx(Text, { children: ` ${keyText} ` }), jsx(Text, { color: Color.Gray, children: actionText })] }));
|
|
2281
2289
|
});
|
|
2282
2290
|
return jsx(Text, { children: usageText });
|
|
2283
2291
|
}
|
|
@@ -2473,10 +2481,10 @@ class SetupReporter {
|
|
|
2473
2481
|
if ("diagnostics" in payload) {
|
|
2474
2482
|
for (const diagnostic of payload.diagnostics) {
|
|
2475
2483
|
switch (diagnostic.category) {
|
|
2476
|
-
case
|
|
2484
|
+
case DiagnosticCategory.Error:
|
|
2477
2485
|
OutputService.writeError(diagnosticText(diagnostic));
|
|
2478
2486
|
break;
|
|
2479
|
-
case
|
|
2487
|
+
case DiagnosticCategory.Warning:
|
|
2480
2488
|
OutputService.writeWarning(diagnosticText(diagnostic));
|
|
2481
2489
|
break;
|
|
2482
2490
|
}
|
|
@@ -2840,7 +2848,7 @@ class WatchService {
|
|
|
2840
2848
|
case "\u001B":
|
|
2841
2849
|
case "q":
|
|
2842
2850
|
case "x":
|
|
2843
|
-
onClose(
|
|
2851
|
+
onClose(CancellationReason.WatchClose);
|
|
2844
2852
|
break;
|
|
2845
2853
|
case "\u000D":
|
|
2846
2854
|
case "\u0020":
|
|
@@ -2875,7 +2883,7 @@ class WatchService {
|
|
|
2875
2883
|
};
|
|
2876
2884
|
this.#watchers.push(new Watcher(this.#resolvedConfig.rootPath, onChangedFile, onRemovedFile, { recursive: true }));
|
|
2877
2885
|
const onChangedConfigFile = () => {
|
|
2878
|
-
onClose(
|
|
2886
|
+
onClose(CancellationReason.ConfigChange);
|
|
2879
2887
|
};
|
|
2880
2888
|
this.#watchers.push(new FileWatcher(this.#resolvedConfig.configFilePath, onChangedConfigFile));
|
|
2881
2889
|
for (const watcher of this.#watchers) {
|
|
@@ -2890,6 +2898,13 @@ class WatchService {
|
|
|
2890
2898
|
}
|
|
2891
2899
|
}
|
|
2892
2900
|
|
|
2901
|
+
var TestMemberBrand;
|
|
2902
|
+
(function (TestMemberBrand) {
|
|
2903
|
+
TestMemberBrand["Describe"] = "describe";
|
|
2904
|
+
TestMemberBrand["Test"] = "test";
|
|
2905
|
+
TestMemberBrand["Expect"] = "expect";
|
|
2906
|
+
})(TestMemberBrand || (TestMemberBrand = {}));
|
|
2907
|
+
|
|
2893
2908
|
class TestMember {
|
|
2894
2909
|
brand;
|
|
2895
2910
|
#compiler;
|
|
@@ -2931,17 +2946,17 @@ class TestMember {
|
|
|
2931
2946
|
return node.parent;
|
|
2932
2947
|
};
|
|
2933
2948
|
switch (this.brand) {
|
|
2934
|
-
case
|
|
2949
|
+
case TestMemberBrand.Describe:
|
|
2935
2950
|
for (const member of this.members) {
|
|
2936
|
-
if (member.brand ===
|
|
2951
|
+
if (member.brand === TestMemberBrand.Expect) {
|
|
2937
2952
|
diagnostics.push(Diagnostic.error(getText(member.node), DiagnosticOrigin.fromNode(getParentCallExpression(member.node))));
|
|
2938
2953
|
}
|
|
2939
2954
|
}
|
|
2940
2955
|
break;
|
|
2941
|
-
case
|
|
2942
|
-
case
|
|
2956
|
+
case TestMemberBrand.Test:
|
|
2957
|
+
case TestMemberBrand.Expect:
|
|
2943
2958
|
for (const member of this.members) {
|
|
2944
|
-
if (member.brand !==
|
|
2959
|
+
if (member.brand !== TestMemberBrand.Expect) {
|
|
2945
2960
|
diagnostics.push(Diagnostic.error(getText(member.node), DiagnosticOrigin.fromNode(member.node)));
|
|
2946
2961
|
}
|
|
2947
2962
|
}
|
|
@@ -2976,6 +2991,15 @@ class Assertion extends TestMember {
|
|
|
2976
2991
|
}
|
|
2977
2992
|
}
|
|
2978
2993
|
|
|
2994
|
+
var TestMemberFlags;
|
|
2995
|
+
(function (TestMemberFlags) {
|
|
2996
|
+
TestMemberFlags[TestMemberFlags["None"] = 0] = "None";
|
|
2997
|
+
TestMemberFlags[TestMemberFlags["Fail"] = 1] = "Fail";
|
|
2998
|
+
TestMemberFlags[TestMemberFlags["Only"] = 2] = "Only";
|
|
2999
|
+
TestMemberFlags[TestMemberFlags["Skip"] = 4] = "Skip";
|
|
3000
|
+
TestMemberFlags[TestMemberFlags["Todo"] = 8] = "Todo";
|
|
3001
|
+
})(TestMemberFlags || (TestMemberFlags = {}));
|
|
3002
|
+
|
|
2979
3003
|
class IdentifierLookup {
|
|
2980
3004
|
#compiler;
|
|
2981
3005
|
#identifiers;
|
|
@@ -3020,7 +3044,7 @@ class IdentifierLookup {
|
|
|
3020
3044
|
}
|
|
3021
3045
|
}
|
|
3022
3046
|
resolveTestMemberMeta(node) {
|
|
3023
|
-
let flags =
|
|
3047
|
+
let flags = TestMemberFlags.None;
|
|
3024
3048
|
let expression = node.expression;
|
|
3025
3049
|
while (this.#compiler.isPropertyAccessExpression(expression)) {
|
|
3026
3050
|
if (expression.expression.getText() === this.#identifiers.namespace) {
|
|
@@ -3028,16 +3052,16 @@ class IdentifierLookup {
|
|
|
3028
3052
|
}
|
|
3029
3053
|
switch (expression.name.getText()) {
|
|
3030
3054
|
case "fail":
|
|
3031
|
-
flags |=
|
|
3055
|
+
flags |= TestMemberFlags.Fail;
|
|
3032
3056
|
break;
|
|
3033
3057
|
case "only":
|
|
3034
|
-
flags |=
|
|
3058
|
+
flags |= TestMemberFlags.Only;
|
|
3035
3059
|
break;
|
|
3036
3060
|
case "skip":
|
|
3037
|
-
flags |=
|
|
3061
|
+
flags |= TestMemberFlags.Skip;
|
|
3038
3062
|
break;
|
|
3039
3063
|
case "todo":
|
|
3040
|
-
flags |=
|
|
3064
|
+
flags |= TestMemberFlags.Todo;
|
|
3041
3065
|
break;
|
|
3042
3066
|
}
|
|
3043
3067
|
expression = expression.expression;
|
|
@@ -3055,12 +3079,12 @@ class IdentifierLookup {
|
|
|
3055
3079
|
}
|
|
3056
3080
|
switch (identifierName) {
|
|
3057
3081
|
case "describe":
|
|
3058
|
-
return { brand:
|
|
3082
|
+
return { brand: TestMemberBrand.Describe, flags };
|
|
3059
3083
|
case "it":
|
|
3060
3084
|
case "test":
|
|
3061
|
-
return { brand:
|
|
3085
|
+
return { brand: TestMemberBrand.Test, flags };
|
|
3062
3086
|
case "expect":
|
|
3063
|
-
return { brand:
|
|
3087
|
+
return { brand: TestMemberBrand.Expect, flags };
|
|
3064
3088
|
}
|
|
3065
3089
|
return;
|
|
3066
3090
|
}
|
|
@@ -3076,7 +3100,7 @@ class TestTree {
|
|
|
3076
3100
|
}
|
|
3077
3101
|
get hasOnly() {
|
|
3078
3102
|
function hasOnly(root) {
|
|
3079
|
-
return root.members.some((branch) => branch.flags &
|
|
3103
|
+
return root.members.some((branch) => branch.flags & TestMemberFlags.Only || ("members" in branch && hasOnly(branch)));
|
|
3080
3104
|
}
|
|
3081
3105
|
return hasOnly(this);
|
|
3082
3106
|
}
|
|
@@ -3090,7 +3114,7 @@ class CollectService {
|
|
|
3090
3114
|
#collectTestMembers(node, identifiers, parent) {
|
|
3091
3115
|
if (this.#compiler.isCallExpression(node)) {
|
|
3092
3116
|
const meta = identifiers.resolveTestMemberMeta(node);
|
|
3093
|
-
if (meta != null && (meta.brand ===
|
|
3117
|
+
if (meta != null && (meta.brand === TestMemberBrand.Describe || meta.brand === TestMemberBrand.Test)) {
|
|
3094
3118
|
const testMember = new TestMember(this.#compiler, meta.brand, node, parent, meta.flags);
|
|
3095
3119
|
parent.members.push(testMember);
|
|
3096
3120
|
this.#compiler.forEachChild(node, (node) => {
|
|
@@ -3098,7 +3122,7 @@ class CollectService {
|
|
|
3098
3122
|
});
|
|
3099
3123
|
return;
|
|
3100
3124
|
}
|
|
3101
|
-
if (meta != null && meta.brand ===
|
|
3125
|
+
if (meta != null && meta.brand === TestMemberBrand.Expect) {
|
|
3102
3126
|
const modifierNode = this.#getChainedNode(node, "type");
|
|
3103
3127
|
if (!modifierNode) {
|
|
3104
3128
|
return;
|
|
@@ -3143,22 +3167,6 @@ class CollectService {
|
|
|
3143
3167
|
}
|
|
3144
3168
|
}
|
|
3145
3169
|
|
|
3146
|
-
var TestMemberBrand;
|
|
3147
|
-
(function (TestMemberBrand) {
|
|
3148
|
-
TestMemberBrand["Describe"] = "describe";
|
|
3149
|
-
TestMemberBrand["Test"] = "test";
|
|
3150
|
-
TestMemberBrand["Expect"] = "expect";
|
|
3151
|
-
})(TestMemberBrand || (TestMemberBrand = {}));
|
|
3152
|
-
|
|
3153
|
-
var TestMemberFlags;
|
|
3154
|
-
(function (TestMemberFlags) {
|
|
3155
|
-
TestMemberFlags[TestMemberFlags["None"] = 0] = "None";
|
|
3156
|
-
TestMemberFlags[TestMemberFlags["Fail"] = 1] = "Fail";
|
|
3157
|
-
TestMemberFlags[TestMemberFlags["Only"] = 2] = "Only";
|
|
3158
|
-
TestMemberFlags[TestMemberFlags["Skip"] = 4] = "Skip";
|
|
3159
|
-
TestMemberFlags[TestMemberFlags["Todo"] = 8] = "Todo";
|
|
3160
|
-
})(TestMemberFlags || (TestMemberFlags = {}));
|
|
3161
|
-
|
|
3162
3170
|
class ProjectService {
|
|
3163
3171
|
#compiler;
|
|
3164
3172
|
#lastSeenProject = "";
|
|
@@ -3261,7 +3269,7 @@ class ProjectService {
|
|
|
3261
3269
|
if (configFileErrors && configFileErrors.length > 0) {
|
|
3262
3270
|
EventEmitter.dispatch([
|
|
3263
3271
|
"project:error",
|
|
3264
|
-
{ diagnostics: Diagnostic.fromDiagnostics(configFileErrors
|
|
3272
|
+
{ diagnostics: Diagnostic.fromDiagnostics(configFileErrors) },
|
|
3265
3273
|
]);
|
|
3266
3274
|
}
|
|
3267
3275
|
if (this.#resolvedConfig.checkSourceFiles) {
|
|
@@ -3285,16 +3293,22 @@ class ProjectService {
|
|
|
3285
3293
|
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile), ...program.getSemanticDiagnostics(sourceFile));
|
|
3286
3294
|
}
|
|
3287
3295
|
if (diagnostics.length > 0) {
|
|
3288
|
-
EventEmitter.dispatch([
|
|
3289
|
-
"project:error",
|
|
3290
|
-
{ diagnostics: Diagnostic.fromDiagnostics(diagnostics, this.#compiler) },
|
|
3291
|
-
]);
|
|
3296
|
+
EventEmitter.dispatch(["project:error", { diagnostics: Diagnostic.fromDiagnostics(diagnostics) }]);
|
|
3292
3297
|
return;
|
|
3293
3298
|
}
|
|
3294
3299
|
}
|
|
3295
3300
|
}
|
|
3296
3301
|
}
|
|
3297
3302
|
|
|
3303
|
+
var RunMode;
|
|
3304
|
+
(function (RunMode) {
|
|
3305
|
+
RunMode[RunMode["Normal"] = 0] = "Normal";
|
|
3306
|
+
RunMode[RunMode["Fail"] = 1] = "Fail";
|
|
3307
|
+
RunMode[RunMode["Only"] = 2] = "Only";
|
|
3308
|
+
RunMode[RunMode["Skip"] = 4] = "Skip";
|
|
3309
|
+
RunMode[RunMode["Todo"] = 8] = "Todo";
|
|
3310
|
+
})(RunMode || (RunMode = {}));
|
|
3311
|
+
|
|
3298
3312
|
class Format {
|
|
3299
3313
|
static capitalize(text) {
|
|
3300
3314
|
return text.replace(/^./, text.charAt(0).toUpperCase());
|
|
@@ -3462,7 +3476,13 @@ class MatchWorker {
|
|
|
3462
3476
|
#checkIsRelatedTo(sourceNode, targetNode, relation) {
|
|
3463
3477
|
const sourceType = this.getType(sourceNode);
|
|
3464
3478
|
const targetType = this.getType(targetNode);
|
|
3465
|
-
|
|
3479
|
+
let result = this.#typeChecker.isTypeRelatedTo(sourceType, targetType, relation);
|
|
3480
|
+
if (!result &&
|
|
3481
|
+
relation === this.#typeChecker.relation.identity &&
|
|
3482
|
+
(sourceType.isIntersection() || sourceType.isUnion())) {
|
|
3483
|
+
result = sourceType.types.every((type) => this.#typeChecker.isTypeRelatedTo(type, targetType, relation));
|
|
3484
|
+
}
|
|
3485
|
+
return result;
|
|
3466
3486
|
}
|
|
3467
3487
|
extendsObjectType(type) {
|
|
3468
3488
|
const nonPrimitiveType = { flags: this.#compiler.TypeFlags.NonPrimitive };
|
|
@@ -3867,7 +3887,7 @@ class ToRaiseError {
|
|
|
3867
3887
|
const text = ExpectDiagnosticText.typeRaisedError(isTypeNode, count, targetNodes.length);
|
|
3868
3888
|
const related = [
|
|
3869
3889
|
Diagnostic.error(ExpectDiagnosticText.raisedTypeError(count)),
|
|
3870
|
-
...Diagnostic.fromDiagnostics([...matchWorker.assertion.diagnostics]
|
|
3890
|
+
...Diagnostic.fromDiagnostics([...matchWorker.assertion.diagnostics]),
|
|
3871
3891
|
];
|
|
3872
3892
|
return [Diagnostic.error(text, origin).add({ related })];
|
|
3873
3893
|
}
|
|
@@ -3881,7 +3901,7 @@ class ToRaiseError {
|
|
|
3881
3901
|
const origin = DiagnosticOrigin.fromNode(targetNode, matchWorker.assertion);
|
|
3882
3902
|
const related = [
|
|
3883
3903
|
Diagnostic.error(ExpectDiagnosticText.raisedTypeError()),
|
|
3884
|
-
...Diagnostic.fromDiagnostics([diagnostic]
|
|
3904
|
+
...Diagnostic.fromDiagnostics([diagnostic]),
|
|
3885
3905
|
];
|
|
3886
3906
|
accumulator.push(Diagnostic.error(text, origin).add({ related }));
|
|
3887
3907
|
}
|
|
@@ -4100,23 +4120,23 @@ class TestTreeWalker {
|
|
|
4100
4120
|
this.#expectService = new ExpectService(compiler, typeChecker, this.#resolvedConfig);
|
|
4101
4121
|
}
|
|
4102
4122
|
#resolveRunMode(mode, member) {
|
|
4103
|
-
if (member.flags &
|
|
4104
|
-
mode |=
|
|
4123
|
+
if (member.flags & TestMemberFlags.Fail) {
|
|
4124
|
+
mode |= RunMode.Fail;
|
|
4105
4125
|
}
|
|
4106
|
-
if (member.flags &
|
|
4126
|
+
if (member.flags & TestMemberFlags.Only ||
|
|
4107
4127
|
(this.#resolvedConfig.only != null && member.name.toLowerCase().includes(this.#resolvedConfig.only.toLowerCase()))) {
|
|
4108
|
-
mode |=
|
|
4128
|
+
mode |= RunMode.Only;
|
|
4109
4129
|
}
|
|
4110
|
-
if (member.flags &
|
|
4130
|
+
if (member.flags & TestMemberFlags.Skip ||
|
|
4111
4131
|
(this.#resolvedConfig.skip != null && member.name.toLowerCase().includes(this.#resolvedConfig.skip.toLowerCase()))) {
|
|
4112
|
-
mode |=
|
|
4132
|
+
mode |= RunMode.Skip;
|
|
4113
4133
|
}
|
|
4114
|
-
if (member.flags &
|
|
4115
|
-
mode |=
|
|
4134
|
+
if (member.flags & TestMemberFlags.Todo) {
|
|
4135
|
+
mode |= RunMode.Todo;
|
|
4116
4136
|
}
|
|
4117
4137
|
if (this.#position != null && member.node.getStart() === this.#position) {
|
|
4118
|
-
mode |=
|
|
4119
|
-
mode &= ~
|
|
4138
|
+
mode |= RunMode.Only;
|
|
4139
|
+
mode &= ~RunMode.Skip;
|
|
4120
4140
|
}
|
|
4121
4141
|
return mode;
|
|
4122
4142
|
}
|
|
@@ -4131,13 +4151,13 @@ class TestTreeWalker {
|
|
|
4131
4151
|
break;
|
|
4132
4152
|
}
|
|
4133
4153
|
switch (member.brand) {
|
|
4134
|
-
case
|
|
4154
|
+
case TestMemberBrand.Describe:
|
|
4135
4155
|
this.#visitDescribe(member, runMode, parentResult);
|
|
4136
4156
|
break;
|
|
4137
|
-
case
|
|
4157
|
+
case TestMemberBrand.Test:
|
|
4138
4158
|
this.#visitTest(member, runMode, parentResult);
|
|
4139
4159
|
break;
|
|
4140
|
-
case
|
|
4160
|
+
case TestMemberBrand.Expect:
|
|
4141
4161
|
this.#visitAssertion(member, runMode, parentResult);
|
|
4142
4162
|
break;
|
|
4143
4163
|
}
|
|
@@ -4148,7 +4168,7 @@ class TestTreeWalker {
|
|
|
4148
4168
|
const expectResult = new ExpectResult(assertion, parentResult);
|
|
4149
4169
|
EventEmitter.dispatch(["expect:start", { result: expectResult }]);
|
|
4150
4170
|
runMode = this.#resolveRunMode(runMode, assertion);
|
|
4151
|
-
if (runMode &
|
|
4171
|
+
if (runMode & RunMode.Skip || (this.#hasOnly && !(runMode & RunMode.Only))) {
|
|
4152
4172
|
EventEmitter.dispatch(["expect:skip", { result: expectResult }]);
|
|
4153
4173
|
return;
|
|
4154
4174
|
}
|
|
@@ -4159,7 +4179,7 @@ class TestTreeWalker {
|
|
|
4159
4179
|
]);
|
|
4160
4180
|
};
|
|
4161
4181
|
if (assertion.diagnostics.size > 0 && assertion.matcherName.getText() !== "toRaiseError") {
|
|
4162
|
-
onExpectDiagnostics(Diagnostic.fromDiagnostics([...assertion.diagnostics]
|
|
4182
|
+
onExpectDiagnostics(Diagnostic.fromDiagnostics([...assertion.diagnostics]));
|
|
4163
4183
|
return;
|
|
4164
4184
|
}
|
|
4165
4185
|
const matchResult = this.#expectService.match(assertion, onExpectDiagnostics);
|
|
@@ -4167,7 +4187,7 @@ class TestTreeWalker {
|
|
|
4167
4187
|
return;
|
|
4168
4188
|
}
|
|
4169
4189
|
if (assertion.isNot ? !matchResult.isMatch : matchResult.isMatch) {
|
|
4170
|
-
if (runMode &
|
|
4190
|
+
if (runMode & RunMode.Fail) {
|
|
4171
4191
|
const text = ["The assertion was supposed to fail, but it passed.", "Consider removing the '.fail' flag."];
|
|
4172
4192
|
const origin = DiagnosticOrigin.fromNode(assertion.node.expression.name);
|
|
4173
4193
|
onExpectDiagnostics(Diagnostic.error(text, origin));
|
|
@@ -4176,7 +4196,7 @@ class TestTreeWalker {
|
|
|
4176
4196
|
EventEmitter.dispatch(["expect:pass", { result: expectResult }]);
|
|
4177
4197
|
}
|
|
4178
4198
|
}
|
|
4179
|
-
else if (runMode &
|
|
4199
|
+
else if (runMode & RunMode.Fail) {
|
|
4180
4200
|
EventEmitter.dispatch(["expect:pass", { result: expectResult }]);
|
|
4181
4201
|
}
|
|
4182
4202
|
else {
|
|
@@ -4187,12 +4207,12 @@ class TestTreeWalker {
|
|
|
4187
4207
|
const describeResult = new DescribeResult(describe, parentResult);
|
|
4188
4208
|
EventEmitter.dispatch(["describe:start", { result: describeResult }]);
|
|
4189
4209
|
runMode = this.#resolveRunMode(runMode, describe);
|
|
4190
|
-
if (!(runMode &
|
|
4210
|
+
if (!(runMode & RunMode.Skip || (this.#hasOnly && !(runMode & RunMode.Only)) || runMode & RunMode.Todo) &&
|
|
4191
4211
|
describe.diagnostics.size > 0) {
|
|
4192
4212
|
EventEmitter.dispatch([
|
|
4193
4213
|
"task:error",
|
|
4194
4214
|
{
|
|
4195
|
-
diagnostics: Diagnostic.fromDiagnostics([...describe.diagnostics]
|
|
4215
|
+
diagnostics: Diagnostic.fromDiagnostics([...describe.diagnostics]),
|
|
4196
4216
|
result: this.#taskResult,
|
|
4197
4217
|
},
|
|
4198
4218
|
]);
|
|
@@ -4206,22 +4226,22 @@ class TestTreeWalker {
|
|
|
4206
4226
|
const testResult = new TestResult(test, parentResult);
|
|
4207
4227
|
EventEmitter.dispatch(["test:start", { result: testResult }]);
|
|
4208
4228
|
runMode = this.#resolveRunMode(runMode, test);
|
|
4209
|
-
if (runMode &
|
|
4229
|
+
if (runMode & RunMode.Todo) {
|
|
4210
4230
|
EventEmitter.dispatch(["test:todo", { result: testResult }]);
|
|
4211
4231
|
return;
|
|
4212
4232
|
}
|
|
4213
|
-
if (!(runMode &
|
|
4233
|
+
if (!(runMode & RunMode.Skip || (this.#hasOnly && !(runMode & RunMode.Only))) && test.diagnostics.size > 0) {
|
|
4214
4234
|
EventEmitter.dispatch([
|
|
4215
4235
|
"test:error",
|
|
4216
4236
|
{
|
|
4217
|
-
diagnostics: Diagnostic.fromDiagnostics([...test.diagnostics]
|
|
4237
|
+
diagnostics: Diagnostic.fromDiagnostics([...test.diagnostics]),
|
|
4218
4238
|
result: testResult,
|
|
4219
4239
|
},
|
|
4220
4240
|
]);
|
|
4221
4241
|
return;
|
|
4222
4242
|
}
|
|
4223
4243
|
this.visit(test.members, runMode, testResult);
|
|
4224
|
-
if (runMode &
|
|
4244
|
+
if (runMode & RunMode.Skip || (this.#hasOnly && !(runMode & RunMode.Only))) {
|
|
4225
4245
|
EventEmitter.dispatch(["test:skip", { result: testResult }]);
|
|
4226
4246
|
return;
|
|
4227
4247
|
}
|
|
@@ -4272,7 +4292,7 @@ class TaskRunner {
|
|
|
4272
4292
|
if (syntacticDiagnostics.length > 0) {
|
|
4273
4293
|
EventEmitter.dispatch([
|
|
4274
4294
|
"task:error",
|
|
4275
|
-
{ diagnostics: Diagnostic.fromDiagnostics(syntacticDiagnostics
|
|
4295
|
+
{ diagnostics: Diagnostic.fromDiagnostics(syntacticDiagnostics), result: taskResult },
|
|
4276
4296
|
]);
|
|
4277
4297
|
return;
|
|
4278
4298
|
}
|
|
@@ -4289,7 +4309,7 @@ class TaskRunner {
|
|
|
4289
4309
|
if (testTree.diagnostics.size > 0) {
|
|
4290
4310
|
EventEmitter.dispatch([
|
|
4291
4311
|
"task:error",
|
|
4292
|
-
{ diagnostics: Diagnostic.fromDiagnostics([...testTree.diagnostics]
|
|
4312
|
+
{ diagnostics: Diagnostic.fromDiagnostics([...testTree.diagnostics]), result: taskResult },
|
|
4293
4313
|
]);
|
|
4294
4314
|
return;
|
|
4295
4315
|
}
|
|
@@ -4300,14 +4320,14 @@ class TaskRunner {
|
|
|
4300
4320
|
hasOnly: testTree.hasOnly,
|
|
4301
4321
|
position: task.position,
|
|
4302
4322
|
});
|
|
4303
|
-
testTreeWalker.visit(testTree.members,
|
|
4323
|
+
testTreeWalker.visit(testTree.members, RunMode.Normal, undefined);
|
|
4304
4324
|
}
|
|
4305
4325
|
}
|
|
4306
4326
|
|
|
4307
4327
|
class Runner {
|
|
4308
4328
|
#eventEmitter = new EventEmitter();
|
|
4309
4329
|
#resolvedConfig;
|
|
4310
|
-
static version = "3.
|
|
4330
|
+
static version = "3.3.0";
|
|
4311
4331
|
constructor(resolvedConfig) {
|
|
4312
4332
|
this.#resolvedConfig = resolvedConfig;
|
|
4313
4333
|
}
|
|
@@ -4342,7 +4362,7 @@ class Runner {
|
|
|
4342
4362
|
this.#eventEmitter.addHandler(resultHandler);
|
|
4343
4363
|
await this.#addReporters();
|
|
4344
4364
|
if (this.#resolvedConfig.failFast) {
|
|
4345
|
-
const cancellationHandler = new CancellationHandler(cancellationToken,
|
|
4365
|
+
const cancellationHandler = new CancellationHandler(cancellationToken, CancellationReason.FailFast);
|
|
4346
4366
|
this.#eventEmitter.addHandler(cancellationHandler);
|
|
4347
4367
|
}
|
|
4348
4368
|
await this.#run(tasks, cancellationToken);
|
|
@@ -4368,7 +4388,7 @@ class Runner {
|
|
|
4368
4388
|
EventEmitter.dispatch(["target:end", { result: targetResult }]);
|
|
4369
4389
|
}
|
|
4370
4390
|
EventEmitter.dispatch(["run:end", { result }]);
|
|
4371
|
-
if (cancellationToken.reason ===
|
|
4391
|
+
if (cancellationToken.reason === CancellationReason.FailFast) {
|
|
4372
4392
|
cancellationToken.reset();
|
|
4373
4393
|
}
|
|
4374
4394
|
}
|
|
@@ -4383,14 +4403,14 @@ class Runner {
|
|
|
4383
4403
|
class Cli {
|
|
4384
4404
|
#eventEmitter = new EventEmitter();
|
|
4385
4405
|
async run(commandLine, cancellationToken = new CancellationToken()) {
|
|
4386
|
-
const cancellationHandler = new CancellationHandler(cancellationToken,
|
|
4406
|
+
const cancellationHandler = new CancellationHandler(cancellationToken, CancellationReason.ConfigError);
|
|
4387
4407
|
this.#eventEmitter.addHandler(cancellationHandler);
|
|
4388
4408
|
const exitCodeHandler = new ExitCodeHandler();
|
|
4389
4409
|
this.#eventEmitter.addHandler(exitCodeHandler);
|
|
4390
4410
|
const setupReporter = new SetupReporter();
|
|
4391
4411
|
this.#eventEmitter.addReporter(setupReporter);
|
|
4392
4412
|
if (commandLine.includes("--help")) {
|
|
4393
|
-
const options = Options.for(
|
|
4413
|
+
const options = Options.for(OptionGroup.CommandLine);
|
|
4394
4414
|
OutputService.writeMessage(helpText(options, Runner.version));
|
|
4395
4415
|
return;
|
|
4396
4416
|
}
|
|
@@ -4418,7 +4438,7 @@ class Cli {
|
|
|
4418
4438
|
return;
|
|
4419
4439
|
}
|
|
4420
4440
|
do {
|
|
4421
|
-
if (cancellationToken.reason ===
|
|
4441
|
+
if (cancellationToken.reason === CancellationReason.ConfigChange) {
|
|
4422
4442
|
cancellationToken.reset();
|
|
4423
4443
|
exitCodeHandler.resetCode();
|
|
4424
4444
|
OutputService.clearTerminal();
|
|
@@ -4473,7 +4493,7 @@ class Cli {
|
|
|
4473
4493
|
const runner = new Runner(resolvedConfig);
|
|
4474
4494
|
await runner.run(testFiles, cancellationToken);
|
|
4475
4495
|
PluginService.removeHandlers();
|
|
4476
|
-
} while (cancellationToken.reason ===
|
|
4496
|
+
} while (cancellationToken.reason === CancellationReason.ConfigChange);
|
|
4477
4497
|
this.#eventEmitter.removeHandlers();
|
|
4478
4498
|
}
|
|
4479
4499
|
#waitForChangedFiles(resolvedConfig, cancellationToken) {
|
|
@@ -4482,7 +4502,7 @@ class Cli {
|
|
|
4482
4502
|
cancellationToken.reset();
|
|
4483
4503
|
OutputService.writeMessage(waitingForFileChangesText());
|
|
4484
4504
|
const onChanged = () => {
|
|
4485
|
-
cancellationToken.cancel(
|
|
4505
|
+
cancellationToken.cancel(CancellationReason.ConfigChange);
|
|
4486
4506
|
for (const watcher of watchers) {
|
|
4487
4507
|
watcher.close();
|
|
4488
4508
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tstyche",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "The Essential Type Testing Tool.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"optional": true
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
"packageManager": "yarn@4.
|
|
86
|
+
"packageManager": "yarn@4.6.0",
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=18.19"
|
|
89
89
|
}
|