tstyche 5.0.0-beta.0 → 5.0.0-beta.1

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.js CHANGED
@@ -50,70 +50,41 @@ class EventEmitter {
50
50
  }
51
51
  }
52
52
 
53
- class Path {
54
- static normalizeSlashes;
55
- static {
56
- if (path.sep === "/") {
57
- Path.normalizeSlashes = (filePath) => filePath;
58
- }
59
- else {
60
- Path.normalizeSlashes = (filePath) => filePath.replace(/\\/g, "/");
61
- }
62
- }
63
- static dirname(filePath) {
64
- return Path.normalizeSlashes(path.dirname(filePath));
65
- }
66
- static join(...filePaths) {
67
- return Path.normalizeSlashes(path.join(...filePaths));
68
- }
69
- static relative(from, to) {
70
- const relativePath = Path.normalizeSlashes(path.relative(from, to));
71
- if (/^\.\.?\//.test(relativePath)) {
72
- return relativePath;
73
- }
74
- return `./${relativePath}`;
75
- }
76
- static resolve(...filePaths) {
77
- return Path.normalizeSlashes(path.resolve(...filePaths));
78
- }
79
- }
80
-
81
- class SourceFile {
82
- fileName;
83
- #lineMap;
53
+ class JsonNode {
54
+ origin;
84
55
  text;
85
- constructor(fileName, text) {
86
- this.fileName = fileName;
56
+ constructor(text, origin) {
57
+ this.origin = origin;
87
58
  this.text = text;
88
- this.#lineMap = this.#createLineMap();
89
59
  }
90
- #createLineMap() {
91
- const result = [0];
92
- let position = 0;
93
- while (position < this.text.length) {
94
- if (this.text.charAt(position - 1) === "\r") {
95
- position++;
96
- }
97
- if (this.text.charAt(position - 1) === "\n") {
98
- result.push(position);
99
- }
100
- position++;
60
+ getValue(options) {
61
+ if (this.text == null) {
62
+ return undefined;
101
63
  }
102
- result.push(position);
103
- return result;
104
- }
105
- getLineStarts() {
106
- return this.#lineMap;
107
- }
108
- getLineAndCharacterOfPosition(position) {
109
- const line = this.#lineMap.findLastIndex((line) => line <= position);
110
- const character = position - this.#lineMap[line];
111
- return { line, character };
64
+ if (/^['"]/.test(this.text)) {
65
+ return this.text.slice(1, -1);
66
+ }
67
+ if (options?.expectsIdentifier) {
68
+ return this.text;
69
+ }
70
+ if (this.text === "true") {
71
+ return true;
72
+ }
73
+ if (this.text === "false") {
74
+ return false;
75
+ }
76
+ if (/^\d/.test(this.text)) {
77
+ return Number.parseFloat(this.text);
78
+ }
79
+ return undefined;
112
80
  }
113
81
  }
114
82
 
115
83
  class SourceService {
116
84
  static #files = new Map();
85
+ static delete(filePath) {
86
+ SourceService.#files.delete(filePath);
87
+ }
117
88
  static get(source) {
118
89
  const file = SourceService.#files.get(source.fileName);
119
90
  if (file != null) {
@@ -225,6 +196,171 @@ var DiagnosticCategory;
225
196
  DiagnosticCategory["Warning"] = "warning";
226
197
  })(DiagnosticCategory || (DiagnosticCategory = {}));
227
198
 
199
+ class JsonScanner {
200
+ #end;
201
+ #position;
202
+ #previousPosition;
203
+ #sourceFile;
204
+ constructor(sourceFile, options) {
205
+ this.#end = options?.end ?? sourceFile.text.length;
206
+ this.#position = options?.start ?? 0;
207
+ this.#previousPosition = options?.start ?? 0;
208
+ this.#sourceFile = sourceFile;
209
+ }
210
+ #getOrigin() {
211
+ return new DiagnosticOrigin(this.#previousPosition, this.#position, this.#sourceFile);
212
+ }
213
+ isRead() {
214
+ return !(this.#position < this.#end);
215
+ }
216
+ #peekCharacter() {
217
+ return this.#sourceFile.text.charAt(this.#position);
218
+ }
219
+ #peekNextCharacter() {
220
+ return this.#sourceFile.text.charAt(this.#position + 1);
221
+ }
222
+ peekToken(token) {
223
+ this.#skipTrivia();
224
+ return this.#peekCharacter() === token;
225
+ }
226
+ read() {
227
+ this.#skipTrivia();
228
+ this.#previousPosition = this.#position;
229
+ if (/[\s,:\]}]/.test(this.#peekCharacter())) {
230
+ return new JsonNode(undefined, this.#getOrigin());
231
+ }
232
+ let text = "";
233
+ let closingTokenText = "";
234
+ if (/[[{'"]/.test(this.#peekCharacter())) {
235
+ text += this.#readCharacter();
236
+ switch (text) {
237
+ case "[":
238
+ closingTokenText = "]";
239
+ break;
240
+ case "{":
241
+ closingTokenText = "}";
242
+ break;
243
+ default:
244
+ closingTokenText = text;
245
+ }
246
+ }
247
+ while (!this.isRead()) {
248
+ text += this.#readCharacter();
249
+ if (text.slice(-1) === closingTokenText || (!closingTokenText && /[\s,:\]}]/.test(this.#peekCharacter()))) {
250
+ break;
251
+ }
252
+ }
253
+ return new JsonNode(text, this.#getOrigin());
254
+ }
255
+ #readCharacter() {
256
+ return this.#sourceFile.text.charAt(this.#position++);
257
+ }
258
+ readToken(token) {
259
+ this.#skipTrivia();
260
+ this.#previousPosition = this.#position;
261
+ const character = this.#peekCharacter();
262
+ if (typeof token === "string" ? token === character : token.test(character)) {
263
+ this.#position++;
264
+ return new JsonNode(character, this.#getOrigin());
265
+ }
266
+ return new JsonNode(undefined, this.#getOrigin());
267
+ }
268
+ #skipTrivia() {
269
+ while (!this.isRead()) {
270
+ if (/\s/.test(this.#peekCharacter())) {
271
+ this.#position++;
272
+ continue;
273
+ }
274
+ if (this.#peekCharacter() === "/") {
275
+ if (this.#peekNextCharacter() === "/") {
276
+ this.#position += 2;
277
+ while (!this.isRead()) {
278
+ if (this.#readCharacter() === "\n") {
279
+ break;
280
+ }
281
+ }
282
+ continue;
283
+ }
284
+ if (this.#peekNextCharacter() === "*") {
285
+ this.#position += 2;
286
+ while (!this.isRead()) {
287
+ if (this.#peekCharacter() === "*" && this.#peekNextCharacter() === "/") {
288
+ this.#position += 2;
289
+ break;
290
+ }
291
+ this.#position++;
292
+ }
293
+ continue;
294
+ }
295
+ }
296
+ break;
297
+ }
298
+ this.#previousPosition = this.#position;
299
+ }
300
+ }
301
+
302
+ class JsonSourceFile {
303
+ fileName;
304
+ #lineMap;
305
+ text;
306
+ constructor(fileName, text) {
307
+ this.fileName = fileName;
308
+ this.text = text;
309
+ this.#lineMap = this.#createLineMap();
310
+ }
311
+ #createLineMap() {
312
+ const result = [0];
313
+ let position = 0;
314
+ while (position < this.text.length) {
315
+ if (this.text.charAt(position - 1) === "\r") {
316
+ position++;
317
+ }
318
+ if (this.text.charAt(position - 1) === "\n") {
319
+ result.push(position);
320
+ }
321
+ position++;
322
+ }
323
+ result.push(position);
324
+ return result;
325
+ }
326
+ getLineStarts() {
327
+ return this.#lineMap;
328
+ }
329
+ getLineAndCharacterOfPosition(position) {
330
+ const line = this.#lineMap.findLastIndex((line) => line <= position);
331
+ const character = position - this.#lineMap[line];
332
+ return { line, character };
333
+ }
334
+ }
335
+
336
+ class Path {
337
+ static normalizeSlashes;
338
+ static {
339
+ if (path.sep === "/") {
340
+ Path.normalizeSlashes = (filePath) => filePath;
341
+ }
342
+ else {
343
+ Path.normalizeSlashes = (filePath) => filePath.replace(/\\/g, "/");
344
+ }
345
+ }
346
+ static dirname(filePath) {
347
+ return Path.normalizeSlashes(path.dirname(filePath));
348
+ }
349
+ static join(...filePaths) {
350
+ return Path.normalizeSlashes(path.join(...filePaths));
351
+ }
352
+ static relative(from, to) {
353
+ const relativePath = Path.normalizeSlashes(path.relative(from, to));
354
+ if (/^\.\.?\//.test(relativePath)) {
355
+ return relativePath;
356
+ }
357
+ return `./${relativePath}`;
358
+ }
359
+ static resolve(...filePaths) {
360
+ return Path.normalizeSlashes(path.resolve(...filePaths));
361
+ }
362
+ }
363
+
228
364
  class ConfigDiagnosticText {
229
365
  static expected(element) {
230
366
  return `Expected ${element}.`;
@@ -1460,148 +1596,15 @@ const defaultOptions = {
1460
1596
  checkSuppressedErrors: true,
1461
1597
  failFast: false,
1462
1598
  fixtureFileMatch: ["**/__fixtures__/*.{ts,tsx}", "**/fixtures/*.{ts,tsx}"],
1463
- plugins: [],
1464
- rejectAnyType: true,
1465
- rejectNeverType: true,
1466
- reporters: ["list", "summary"],
1467
- rootPath: Path.resolve("./"),
1468
- target: ["*"],
1469
- testFileMatch: ["**/*.tst.*", "**/__typetests__/*.test.*", "**/typetests/*.test.*"],
1470
- tsconfig: "findup",
1471
- };
1472
-
1473
- class JsonNode {
1474
- origin;
1475
- text;
1476
- constructor(text, origin) {
1477
- this.origin = origin;
1478
- this.text = text;
1479
- }
1480
- getValue(options) {
1481
- if (this.text == null) {
1482
- return undefined;
1483
- }
1484
- if (/^['"]/.test(this.text)) {
1485
- return this.text.slice(1, -1);
1486
- }
1487
- if (options?.expectsIdentifier) {
1488
- return this.text;
1489
- }
1490
- if (this.text === "true") {
1491
- return true;
1492
- }
1493
- if (this.text === "false") {
1494
- return false;
1495
- }
1496
- if (/^\d/.test(this.text)) {
1497
- return Number.parseFloat(this.text);
1498
- }
1499
- return undefined;
1500
- }
1501
- }
1502
-
1503
- class JsonScanner {
1504
- #end;
1505
- #position;
1506
- #previousPosition;
1507
- #sourceFile;
1508
- constructor(sourceFile, options) {
1509
- this.#end = options?.end ?? sourceFile.text.length;
1510
- this.#position = options?.start ?? 0;
1511
- this.#previousPosition = options?.start ?? 0;
1512
- this.#sourceFile = sourceFile;
1513
- }
1514
- #getOrigin() {
1515
- return new DiagnosticOrigin(this.#previousPosition, this.#position, this.#sourceFile);
1516
- }
1517
- isRead() {
1518
- return !(this.#position < this.#end);
1519
- }
1520
- #peekCharacter() {
1521
- return this.#sourceFile.text.charAt(this.#position);
1522
- }
1523
- #peekNextCharacter() {
1524
- return this.#sourceFile.text.charAt(this.#position + 1);
1525
- }
1526
- peekToken(token) {
1527
- this.#skipTrivia();
1528
- return this.#peekCharacter() === token;
1529
- }
1530
- read() {
1531
- this.#skipTrivia();
1532
- this.#previousPosition = this.#position;
1533
- if (/[\s,:\]}]/.test(this.#peekCharacter())) {
1534
- return new JsonNode(undefined, this.#getOrigin());
1535
- }
1536
- let text = "";
1537
- let closingTokenText = "";
1538
- if (/[[{'"]/.test(this.#peekCharacter())) {
1539
- text += this.#readCharacter();
1540
- switch (text) {
1541
- case "[":
1542
- closingTokenText = "]";
1543
- break;
1544
- case "{":
1545
- closingTokenText = "}";
1546
- break;
1547
- default:
1548
- closingTokenText = text;
1549
- }
1550
- }
1551
- while (!this.isRead()) {
1552
- text += this.#readCharacter();
1553
- if (text.slice(-1) === closingTokenText || (!closingTokenText && /[\s,:\]}]/.test(this.#peekCharacter()))) {
1554
- break;
1555
- }
1556
- }
1557
- return new JsonNode(text, this.#getOrigin());
1558
- }
1559
- #readCharacter() {
1560
- return this.#sourceFile.text.charAt(this.#position++);
1561
- }
1562
- readToken(token) {
1563
- this.#skipTrivia();
1564
- this.#previousPosition = this.#position;
1565
- const character = this.#peekCharacter();
1566
- if (typeof token === "string" ? token === character : token.test(character)) {
1567
- this.#position++;
1568
- return new JsonNode(character, this.#getOrigin());
1569
- }
1570
- return new JsonNode(undefined, this.#getOrigin());
1571
- }
1572
- #skipTrivia() {
1573
- while (!this.isRead()) {
1574
- if (/\s/.test(this.#peekCharacter())) {
1575
- this.#position++;
1576
- continue;
1577
- }
1578
- if (this.#peekCharacter() === "/") {
1579
- if (this.#peekNextCharacter() === "/") {
1580
- this.#position += 2;
1581
- while (!this.isRead()) {
1582
- if (this.#readCharacter() === "\n") {
1583
- break;
1584
- }
1585
- }
1586
- continue;
1587
- }
1588
- if (this.#peekNextCharacter() === "*") {
1589
- this.#position += 2;
1590
- while (!this.isRead()) {
1591
- if (this.#peekCharacter() === "*" && this.#peekNextCharacter() === "/") {
1592
- this.#position += 2;
1593
- break;
1594
- }
1595
- this.#position++;
1596
- }
1597
- continue;
1598
- }
1599
- }
1600
- break;
1601
- }
1602
- this.#previousPosition = this.#position;
1603
- }
1604
- }
1599
+ plugins: [],
1600
+ rejectAnyType: true,
1601
+ rejectNeverType: true,
1602
+ reporters: ["list", "summary"],
1603
+ rootPath: Path.resolve("./"),
1604
+ target: ["*"],
1605
+ testFileMatch: ["**/*.tst.*", "**/__typetests__/*.test.*", "**/typetests/*.test.*"],
1606
+ tsconfig: "findup",
1607
+ };
1605
1608
 
1606
1609
  class Config {
1607
1610
  static #onDiagnostics(diagnostic) {
@@ -1623,7 +1626,7 @@ class Config {
1623
1626
  const configFileText = await fs.readFile(configFilePath, {
1624
1627
  encoding: "utf8",
1625
1628
  });
1626
- const sourceFile = new SourceFile(configFilePath, configFileText);
1629
+ const sourceFile = new JsonSourceFile(configFilePath, configFileText);
1627
1630
  const configFileParser = new ConfigParser(configFileOptions, 4, sourceFile, new JsonScanner(sourceFile), Config.#onDiagnostics);
1628
1631
  await configFileParser.parse();
1629
1632
  }
@@ -1827,19 +1830,33 @@ class ExitCodeHandler {
1827
1830
  }
1828
1831
  }
1829
1832
 
1830
- class ResultTiming {
1831
- end = Number.NaN;
1832
- start = Number.NaN;
1833
- get duration() {
1834
- return this.end - this.start;
1835
- }
1833
+ function createObjectFromKeys(keys, defaultValue) {
1834
+ return Object.fromEntries(keys.map((key) => [key, defaultValue]));
1835
+ }
1836
+ function createTargetCounts() {
1837
+ return createObjectFromKeys(["failed", "passed"], 0);
1838
+ }
1839
+ function createFileCounts() {
1840
+ return createObjectFromKeys(["failed", "passed"], 0);
1841
+ }
1842
+ function createTestCounts() {
1843
+ return createObjectFromKeys(["failed", "passed", "fixme", "skipped", "todo"], 0);
1844
+ }
1845
+ function createAssertionCounts() {
1846
+ return createObjectFromKeys(["failed", "passed", "fixme", "skipped", "todo"], 0);
1847
+ }
1848
+ function createSuppressedCounts() {
1849
+ return createObjectFromKeys(["failed", "matched", "ignored"], 0);
1850
+ }
1851
+ function createResultTiming() {
1852
+ return createObjectFromKeys(["start", "end"], Number.NaN);
1836
1853
  }
1837
1854
 
1838
1855
  class DescribeResult {
1839
1856
  describe;
1840
1857
  parent;
1841
1858
  results = [];
1842
- timing = new ResultTiming();
1859
+ timing = createResultTiming();
1843
1860
  constructor(describe, parent) {
1844
1861
  this.describe = describe;
1845
1862
  this.parent = parent;
@@ -1848,35 +1865,23 @@ class DescribeResult {
1848
1865
 
1849
1866
  class ExpectResult {
1850
1867
  expect;
1851
- diagnostics = [];
1852
1868
  parent;
1853
1869
  status = "runs";
1854
- timing = new ResultTiming();
1870
+ timing = createResultTiming();
1855
1871
  constructor(expect, parent) {
1856
1872
  this.expect = expect;
1857
1873
  this.parent = parent;
1858
1874
  }
1859
1875
  }
1860
1876
 
1861
- class ResultCount {
1862
- failed = 0;
1863
- passed = 0;
1864
- skipped = 0;
1865
- fixme = 0;
1866
- todo = 0;
1867
- get total() {
1868
- return this.failed + this.passed + this.skipped + this.fixme + this.todo;
1869
- }
1870
- }
1871
-
1872
1877
  class FileResult {
1873
- diagnostics = [];
1874
- expectCount = new ResultCount();
1878
+ assertionCounts = createAssertionCounts();
1875
1879
  file;
1876
1880
  results = [];
1881
+ suppressedCounts = createSuppressedCounts();
1877
1882
  status = "runs";
1878
- testCount = new ResultCount();
1879
- timing = new ResultTiming();
1883
+ testCounts = createTestCounts();
1884
+ timing = createResultTiming();
1880
1885
  constructor(file) {
1881
1886
  this.file = file;
1882
1887
  }
@@ -1884,7 +1889,6 @@ class FileResult {
1884
1889
 
1885
1890
  class ProjectResult {
1886
1891
  compilerVersion;
1887
- diagnostics = [];
1888
1892
  projectConfigFilePath;
1889
1893
  results = [];
1890
1894
  constructor(compilerVersion, projectConfigFilePath) {
@@ -1894,13 +1898,14 @@ class ProjectResult {
1894
1898
  }
1895
1899
 
1896
1900
  class Result {
1897
- expectCount = new ResultCount();
1898
- fileCount = new ResultCount();
1901
+ assertionCounts = createAssertionCounts();
1902
+ fileCounts = createFileCounts();
1899
1903
  files;
1900
1904
  results = [];
1901
- targetCount = new ResultCount();
1902
- testCount = new ResultCount();
1903
- timing = new ResultTiming();
1905
+ suppressedCounts = createSuppressedCounts();
1906
+ targetCounts = createTargetCounts();
1907
+ testCounts = createTestCounts();
1908
+ timing = createResultTiming();
1904
1909
  constructor(files) {
1905
1910
  this.files = files;
1906
1911
  }
@@ -1910,18 +1915,27 @@ var ResultStatus;
1910
1915
  (function (ResultStatus) {
1911
1916
  ResultStatus["Runs"] = "runs";
1912
1917
  ResultStatus["Passed"] = "passed";
1918
+ ResultStatus["Matched"] = "matched";
1913
1919
  ResultStatus["Failed"] = "failed";
1914
- ResultStatus["Skipped"] = "skipped";
1915
1920
  ResultStatus["Fixme"] = "fixme";
1921
+ ResultStatus["Skipped"] = "skipped";
1922
+ ResultStatus["Ignored"] = "ignored";
1916
1923
  ResultStatus["Todo"] = "todo";
1917
1924
  })(ResultStatus || (ResultStatus = {}));
1918
1925
 
1926
+ class SuppressedResult {
1927
+ suppressed;
1928
+ constructor(suppressed) {
1929
+ this.suppressed = suppressed;
1930
+ }
1931
+ }
1932
+
1919
1933
  class TargetResult {
1920
1934
  files;
1921
1935
  results = new Map();
1922
1936
  status = "runs";
1923
1937
  target;
1924
- timing = new ResultTiming();
1938
+ timing = createResultTiming();
1925
1939
  constructor(target, files) {
1926
1940
  this.target = target;
1927
1941
  this.files = files;
@@ -1929,13 +1943,12 @@ class TargetResult {
1929
1943
  }
1930
1944
 
1931
1945
  class TestResult {
1932
- diagnostics = [];
1933
- expectCount = new ResultCount();
1946
+ assertionCounts = createAssertionCounts();
1934
1947
  parent;
1935
1948
  results = [];
1936
1949
  status = "runs";
1937
1950
  test;
1938
- timing = new ResultTiming();
1951
+ timing = createResultTiming();
1939
1952
  constructor(test, parent) {
1940
1953
  this.test = test;
1941
1954
  this.parent = parent;
@@ -1967,10 +1980,10 @@ class ResultHandler {
1967
1980
  break;
1968
1981
  case "target:end":
1969
1982
  if (this.#targetResult.status === "failed") {
1970
- this.#result.targetCount.failed++;
1983
+ this.#result.targetCounts.failed++;
1971
1984
  }
1972
1985
  else {
1973
- this.#result.targetCount.passed++;
1986
+ this.#result.targetCounts.passed++;
1974
1987
  this.#targetResult.status = "passed";
1975
1988
  }
1976
1989
  this.#targetResult.timing.end = Date.now();
@@ -1992,7 +2005,6 @@ class ResultHandler {
1992
2005
  }
1993
2006
  case "project:error":
1994
2007
  this.#targetResult.status = "failed";
1995
- this.#projectResult.diagnostics.push(...payload.diagnostics);
1996
2008
  break;
1997
2009
  case "file:start":
1998
2010
  this.#projectResult.results.push(payload.result);
@@ -2004,18 +2016,17 @@ class ResultHandler {
2004
2016
  case "collect:error":
2005
2017
  this.#targetResult.status = "failed";
2006
2018
  this.#fileResult.status = "failed";
2007
- this.#fileResult.diagnostics.push(...payload.diagnostics);
2008
2019
  break;
2009
2020
  case "file:end":
2010
2021
  if (this.#fileResult.status === "failed" ||
2011
- this.#fileResult.expectCount.failed > 0 ||
2012
- this.#fileResult.testCount.failed > 0) {
2013
- this.#result.fileCount.failed++;
2022
+ this.#fileResult.assertionCounts.failed > 0 ||
2023
+ this.#fileResult.testCounts.failed > 0) {
2024
+ this.#result.fileCounts.failed++;
2014
2025
  this.#targetResult.status = "failed";
2015
2026
  this.#fileResult.status = "failed";
2016
2027
  }
2017
2028
  else {
2018
- this.#result.fileCount.passed++;
2029
+ this.#result.fileCounts.passed++;
2019
2030
  this.#fileResult.status = "passed";
2020
2031
  }
2021
2032
  this.#fileResult.timing.end = Date.now();
@@ -2046,44 +2057,37 @@ class ResultHandler {
2046
2057
  this.#testResult.timing.start = Date.now();
2047
2058
  break;
2048
2059
  case "test:error":
2049
- this.#result.testCount.failed++;
2050
- this.#fileResult.testCount.failed++;
2051
- this.#testResult.status = "failed";
2052
- this.#testResult.diagnostics.push(...payload.diagnostics);
2053
- this.#testResult.timing.end = Date.now();
2054
- this.#testResult = undefined;
2055
- break;
2056
2060
  case "test:fail":
2057
- this.#result.testCount.failed++;
2058
- this.#fileResult.testCount.failed++;
2061
+ this.#result.testCounts.failed++;
2062
+ this.#fileResult.testCounts.failed++;
2059
2063
  this.#testResult.status = "failed";
2060
2064
  this.#testResult.timing.end = Date.now();
2061
2065
  this.#testResult = undefined;
2062
2066
  break;
2063
2067
  case "test:pass":
2064
- this.#result.testCount.passed++;
2065
- this.#fileResult.testCount.passed++;
2068
+ this.#result.testCounts.passed++;
2069
+ this.#fileResult.testCounts.passed++;
2066
2070
  this.#testResult.status = "passed";
2067
2071
  this.#testResult.timing.end = Date.now();
2068
2072
  this.#testResult = undefined;
2069
2073
  break;
2070
2074
  case "test:skip":
2071
- this.#result.testCount.skipped++;
2072
- this.#fileResult.testCount.skipped++;
2075
+ this.#result.testCounts.skipped++;
2076
+ this.#fileResult.testCounts.skipped++;
2073
2077
  this.#testResult.status = "skipped";
2074
2078
  this.#testResult.timing.end = Date.now();
2075
2079
  this.#testResult = undefined;
2076
2080
  break;
2077
2081
  case "test:fixme":
2078
- this.#result.testCount.fixme++;
2079
- this.#fileResult.testCount.fixme++;
2082
+ this.#result.testCounts.fixme++;
2083
+ this.#fileResult.testCounts.fixme++;
2080
2084
  this.#testResult.status = "fixme";
2081
2085
  this.#testResult.timing.end = Date.now();
2082
2086
  this.#testResult = undefined;
2083
2087
  break;
2084
2088
  case "test:todo":
2085
- this.#result.testCount.todo++;
2086
- this.#fileResult.testCount.todo++;
2089
+ this.#result.testCounts.todo++;
2090
+ this.#fileResult.testCounts.todo++;
2087
2091
  this.#testResult.status = "todo";
2088
2092
  this.#testResult.timing.end = Date.now();
2089
2093
  this.#testResult = undefined;
@@ -2099,56 +2103,60 @@ class ResultHandler {
2099
2103
  this.#expectResult.timing.start = Date.now();
2100
2104
  break;
2101
2105
  case "expect:error":
2102
- this.#result.expectCount.failed++;
2103
- this.#fileResult.expectCount.failed++;
2104
- if (this.#testResult) {
2105
- this.#testResult.expectCount.failed++;
2106
- }
2107
- this.#expectResult.status = "failed";
2108
- this.#expectResult.diagnostics.push(...payload.diagnostics);
2109
- this.#expectResult.timing.end = Date.now();
2110
- this.#expectResult = undefined;
2111
- break;
2112
2106
  case "expect:fail":
2113
- this.#result.expectCount.failed++;
2114
- this.#fileResult.expectCount.failed++;
2107
+ this.#result.assertionCounts.failed++;
2108
+ this.#fileResult.assertionCounts.failed++;
2115
2109
  if (this.#testResult) {
2116
- this.#testResult.expectCount.failed++;
2110
+ this.#testResult.assertionCounts.failed++;
2117
2111
  }
2118
2112
  this.#expectResult.status = "failed";
2119
2113
  this.#expectResult.timing.end = Date.now();
2120
2114
  this.#expectResult = undefined;
2121
2115
  break;
2122
2116
  case "expect:pass":
2123
- this.#result.expectCount.passed++;
2124
- this.#fileResult.expectCount.passed++;
2117
+ this.#result.assertionCounts.passed++;
2118
+ this.#fileResult.assertionCounts.passed++;
2125
2119
  if (this.#testResult) {
2126
- this.#testResult.expectCount.passed++;
2120
+ this.#testResult.assertionCounts.passed++;
2127
2121
  }
2128
2122
  this.#expectResult.status = "passed";
2129
2123
  this.#expectResult.timing.end = Date.now();
2130
2124
  this.#expectResult = undefined;
2131
2125
  break;
2132
2126
  case "expect:skip":
2133
- this.#result.expectCount.skipped++;
2134
- this.#fileResult.expectCount.skipped++;
2127
+ this.#result.assertionCounts.skipped++;
2128
+ this.#fileResult.assertionCounts.skipped++;
2135
2129
  if (this.#testResult) {
2136
- this.#testResult.expectCount.skipped++;
2130
+ this.#testResult.assertionCounts.skipped++;
2137
2131
  }
2138
2132
  this.#expectResult.status = "skipped";
2139
2133
  this.#expectResult.timing.end = Date.now();
2140
2134
  this.#expectResult = undefined;
2141
2135
  break;
2142
2136
  case "expect:fixme":
2143
- this.#result.expectCount.fixme++;
2144
- this.#fileResult.expectCount.fixme++;
2137
+ this.#result.assertionCounts.fixme++;
2138
+ this.#fileResult.assertionCounts.fixme++;
2145
2139
  if (this.#testResult) {
2146
- this.#testResult.expectCount.fixme++;
2140
+ this.#testResult.assertionCounts.fixme++;
2147
2141
  }
2148
2142
  this.#expectResult.status = "fixme";
2149
2143
  this.#expectResult.timing.end = Date.now();
2150
2144
  this.#expectResult = undefined;
2151
2145
  break;
2146
+ case "suppressed:error":
2147
+ this.#result.suppressedCounts.failed++;
2148
+ this.#fileResult.suppressedCounts.failed++;
2149
+ this.#targetResult.status = "failed";
2150
+ this.#fileResult.status = "failed";
2151
+ break;
2152
+ case "suppressed:match":
2153
+ this.#result.suppressedCounts.matched++;
2154
+ this.#fileResult.suppressedCounts.matched++;
2155
+ break;
2156
+ case "suppressed:ignore":
2157
+ this.#result.suppressedCounts.ignored++;
2158
+ this.#fileResult.suppressedCounts.ignored++;
2159
+ break;
2152
2160
  }
2153
2161
  }
2154
2162
  }
@@ -2331,6 +2339,30 @@ function diagnosticText(diagnostic, codeFrameOptions = {}) {
2331
2339
  return (jsx(Text, { children: [prefix, jsx(DiagnosticText, { codeFrameOptions: codeFrameOptions, diagnostic: diagnostic })] }));
2332
2340
  }
2333
2341
 
2342
+ function getStatusColor(status) {
2343
+ switch (status) {
2344
+ case "runs":
2345
+ return "33";
2346
+ case "passed":
2347
+ case "matched":
2348
+ return "32";
2349
+ case "failed":
2350
+ return "31";
2351
+ case "fixme":
2352
+ case "skipped":
2353
+ case "ignored":
2354
+ return "33";
2355
+ case "todo":
2356
+ return "35";
2357
+ }
2358
+ }
2359
+ function duration(timing) {
2360
+ return timing.end - timing.start;
2361
+ }
2362
+ function total(counts) {
2363
+ return Object.values(counts).reduce((sum, value) => sum + value, 0);
2364
+ }
2365
+
2334
2366
  function FileNameText({ filePath }) {
2335
2367
  const relativePath = Path.relative("", filePath);
2336
2368
  const lastPathSeparator = relativePath.lastIndexOf("/");
@@ -2339,23 +2371,19 @@ function FileNameText({ filePath }) {
2339
2371
  return (jsx(Text, { children: [jsx(Text, { color: "90", children: directoryNameText }), fileNameText] }));
2340
2372
  }
2341
2373
  function fileStatusText(status, file) {
2342
- let statusColor;
2343
2374
  let statusText;
2344
2375
  switch (status) {
2345
2376
  case "runs":
2346
- statusColor = "33";
2347
2377
  statusText = "runs";
2348
2378
  break;
2349
2379
  case "passed":
2350
- statusColor = "32";
2351
2380
  statusText = "pass";
2352
2381
  break;
2353
2382
  case "failed":
2354
- statusColor = "31";
2355
2383
  statusText = "fail";
2356
2384
  break;
2357
2385
  }
2358
- return (jsx(Line, { children: [jsx(Text, { color: statusColor, children: statusText }), " ", jsx(FileNameText, { filePath: file.path })] }));
2386
+ return (jsx(Line, { children: [jsx(Text, { color: getStatusColor(status), children: statusText }), " ", jsx(FileNameText, { filePath: file.path })] }));
2359
2387
  }
2360
2388
 
2361
2389
  function fileViewText(lines, addEmptyFinalLine) {
@@ -2466,36 +2494,52 @@ class OutputService {
2466
2494
  function RowText({ label, text }) {
2467
2495
  return (jsx(Line, { children: [`${label}:`.padEnd(12), text] }));
2468
2496
  }
2469
- function CountText({ failed, fixme, passed, skipped, todo, total }) {
2470
- return (jsx(Text, { children: [failed > 0 ? (jsx(Text, { children: [jsx(Text, { color: "31", children: [failed, " failed"] }), jsx(Text, { children: ", " })] })) : undefined, fixme > 0 ? (jsx(Text, { children: [jsx(Text, { color: "33", children: [fixme, " fixme"] }), jsx(Text, { children: ", " })] })) : undefined, skipped > 0 ? (jsx(Text, { children: [jsx(Text, { color: "33", children: [skipped, " skipped"] }), jsx(Text, { children: ", " })] })) : undefined, todo > 0 ? (jsx(Text, { children: [jsx(Text, { color: "35", children: [todo, " todo"] }), jsx(Text, { children: ", " })] })) : undefined, passed > 0 ? (jsx(Text, { children: [jsx(Text, { color: "32", children: [passed, " passed"] }), jsx(Text, { children: ", " })] })) : undefined, jsx(Text, { children: [total, " total"] })] }));
2497
+ function CountsText({ counts, total }) {
2498
+ const countsText = Object.entries(counts).map(([status, count]) => {
2499
+ return (jsx(Text, { children: count > 0 ? (jsx(Text, { children: [jsx(Text, { color: getStatusColor(status), children: [count, " ", status] }), jsx(Text, { children: ", " })] })) : undefined }));
2500
+ });
2501
+ const totalText = (jsx(Text, { children: [total, " ", "total"] }));
2502
+ return (jsx(Text, { children: [countsText, totalText] }));
2471
2503
  }
2472
- function DurationText({ seconds }) {
2504
+ function DurationText({ timing }) {
2505
+ const seconds = duration(timing) / 1000;
2473
2506
  return jsx(Text, { children: `${Math.round(seconds * 10) / 10}s` });
2474
2507
  }
2475
- function summaryText({ duration, expectCount, fileCount, targetCount, testCount, }) {
2476
- const targetCountText = (jsx(RowText, { label: "Targets", text: jsx(CountText, { failed: targetCount.failed, fixme: targetCount.fixme, passed: targetCount.passed, skipped: targetCount.skipped, todo: targetCount.todo, total: targetCount.total }) }));
2477
- const fileCountText = (jsx(RowText, { label: "Test files", text: jsx(CountText, { failed: fileCount.failed, fixme: fileCount.fixme, passed: fileCount.passed, skipped: fileCount.skipped, todo: fileCount.todo, total: fileCount.total }) }));
2478
- const testCountText = (jsx(RowText, { label: "Tests", text: jsx(CountText, { failed: testCount.failed, fixme: testCount.fixme, passed: testCount.passed, skipped: testCount.skipped, todo: testCount.todo, total: testCount.total }) }));
2479
- const assertionCountText = (jsx(RowText, { label: "Assertions", text: jsx(CountText, { failed: expectCount.failed, fixme: expectCount.fixme, passed: expectCount.passed, skipped: expectCount.skipped, todo: expectCount.todo, total: expectCount.total }) }));
2480
- return (jsx(Text, { children: [targetCountText, fileCountText, testCount.total > 0 ? testCountText : undefined, expectCount.total > 0 ? assertionCountText : undefined, jsx(RowText, { label: "Duration", text: jsx(DurationText, { seconds: duration / 1000 }) })] }));
2508
+ function summaryText({ targetCounts, fileCounts, testCounts, assertionCounts, suppressedCounts, timing, }) {
2509
+ const targetCountsTotal = total(targetCounts);
2510
+ const targetCountsText = (jsx(RowText, { label: "Targets", text: jsx(CountsText, { counts: targetCounts, total: targetCountsTotal }) }));
2511
+ const fileCountsTotal = total(fileCounts);
2512
+ const fileCountsText = (jsx(RowText, { label: "Test files", text: jsx(CountsText, { counts: fileCounts, total: fileCountsTotal }) }));
2513
+ const testCountsTotal = total(testCounts);
2514
+ const testCountsText = testCountsTotal > 0 ? (jsx(RowText, { label: "Tests", text: jsx(CountsText, { counts: testCounts, total: testCountsTotal }) })) : undefined;
2515
+ const assertionCountsTotal = total(assertionCounts);
2516
+ const assertionCountsText = assertionCountsTotal > 0 ? (jsx(RowText, { label: "Assertions", text: jsx(CountsText, { counts: assertionCounts, total: assertionCountsTotal }) })) : undefined;
2517
+ const suppressedCountsTotal = total(suppressedCounts);
2518
+ const suppressedCountsText = suppressedCountsTotal > 0 ? (jsx(RowText, { label: "Suppressed", text: jsx(CountsText, { counts: suppressedCounts, total: suppressedCountsTotal }) })) : undefined;
2519
+ const durationText = jsx(RowText, { label: "Duration", text: jsx(DurationText, { timing: timing }) });
2520
+ return (jsx(Text, { children: [targetCountsText, fileCountsText, testCountsText, assertionCountsText, suppressedCountsText, durationText] }));
2481
2521
  }
2482
2522
 
2483
- function StatusText({ status }) {
2523
+ function testNameText(status, name, indent = 0) {
2524
+ let statusText;
2484
2525
  switch (status) {
2485
- case "fail":
2486
- return jsx(Text, { color: "31", children: "\u00D7" });
2487
- case "pass":
2488
- return jsx(Text, { color: "32", children: "+" });
2489
- case "skip":
2490
- return jsx(Text, { color: "33", children: "- skip" });
2526
+ case "passed":
2527
+ statusText = "+";
2528
+ break;
2529
+ case "failed":
2530
+ statusText = "×";
2531
+ break;
2532
+ case "skipped":
2533
+ statusText = "- skip";
2534
+ break;
2491
2535
  case "fixme":
2492
- return jsx(Text, { color: "33", children: "- fixme" });
2536
+ statusText = "- fixme";
2537
+ break;
2493
2538
  case "todo":
2494
- return jsx(Text, { color: "35", children: "- todo" });
2539
+ statusText = "- todo";
2540
+ break;
2495
2541
  }
2496
- }
2497
- function testNameText(status, name, indent = 0) {
2498
- return (jsx(Line, { indent: indent + 1, children: [jsx(StatusText, { status: status }), " ", jsx(Text, { color: "90", children: name })] }));
2542
+ return (jsx(Line, { indent: indent + 1, children: [jsx(Text, { color: getStatusColor(status), children: statusText }), " ", jsx(Text, { color: "90", children: name })] }));
2499
2543
  }
2500
2544
 
2501
2545
  function usesCompilerText(compilerVersion, projectConfigFilePath, options) {
@@ -2630,6 +2674,7 @@ class ListReporter extends BaseReporter {
2630
2674
  case "file:error":
2631
2675
  case "directive:error":
2632
2676
  case "collect:error":
2677
+ case "suppressed:error":
2633
2678
  for (const diagnostic of payload.diagnostics) {
2634
2679
  this.#fileView.addMessage(diagnosticText(diagnostic));
2635
2680
  }
@@ -2658,7 +2703,7 @@ class ListReporter extends BaseReporter {
2658
2703
  break;
2659
2704
  case "test:skip":
2660
2705
  if (this.#isFileViewExpanded) {
2661
- this.#fileView.addTest("skip", payload.result.test.name);
2706
+ this.#fileView.addTest("skipped", payload.result.test.name);
2662
2707
  }
2663
2708
  break;
2664
2709
  case "test:fixme":
@@ -2673,7 +2718,7 @@ class ListReporter extends BaseReporter {
2673
2718
  break;
2674
2719
  case "test:error":
2675
2720
  if (this.#isFileViewExpanded) {
2676
- this.#fileView.addTest("fail", payload.result.test.name);
2721
+ this.#fileView.addTest("failed", payload.result.test.name);
2677
2722
  }
2678
2723
  for (const diagnostic of payload.diagnostics) {
2679
2724
  this.#fileView.addMessage(diagnosticText(diagnostic));
@@ -2681,12 +2726,12 @@ class ListReporter extends BaseReporter {
2681
2726
  break;
2682
2727
  case "test:fail":
2683
2728
  if (this.#isFileViewExpanded) {
2684
- this.#fileView.addTest("fail", payload.result.test.name);
2729
+ this.#fileView.addTest("failed", payload.result.test.name);
2685
2730
  }
2686
2731
  break;
2687
2732
  case "test:pass":
2688
2733
  if (this.#isFileViewExpanded) {
2689
- this.#fileView.addTest("pass", payload.result.test.name);
2734
+ this.#fileView.addTest("passed", payload.result.test.name);
2690
2735
  }
2691
2736
  break;
2692
2737
  case "expect:error":
@@ -2727,11 +2772,12 @@ class SummaryReporter extends BaseReporter {
2727
2772
  }
2728
2773
  if (event === "run:end") {
2729
2774
  OutputService.writeMessage(summaryText({
2730
- duration: payload.result.timing.duration,
2731
- expectCount: payload.result.expectCount,
2732
- fileCount: payload.result.fileCount,
2733
- targetCount: payload.result.targetCount,
2734
- testCount: payload.result.testCount,
2775
+ targetCounts: payload.result.targetCounts,
2776
+ fileCounts: payload.result.fileCounts,
2777
+ testCounts: payload.result.testCounts,
2778
+ assertionCounts: payload.result.assertionCounts,
2779
+ suppressedCounts: payload.result.suppressedCounts,
2780
+ timing: payload.result.timing,
2735
2781
  }));
2736
2782
  }
2737
2783
  }
@@ -3188,8 +3234,28 @@ class WatchService {
3188
3234
  }
3189
3235
  }
3190
3236
 
3191
- function nodeBelongsToArgumentList(compiler, node) {
3192
- return compiler.isCallExpression(node.parent) && node.parent.arguments.some((argument) => argument === node);
3237
+ function compareDiagnostics(a, b) {
3238
+ if (a.file?.fileName !== b.file?.fileName) {
3239
+ return false;
3240
+ }
3241
+ return deepCompareKeys(a, b, ["start", "length", "code", "messageText"]);
3242
+ }
3243
+ function deepCompareKeys(a, b, keys) {
3244
+ if (a == null || b == null) {
3245
+ return a === b;
3246
+ }
3247
+ if (typeof a !== typeof b) {
3248
+ return false;
3249
+ }
3250
+ if (typeof a !== "object") {
3251
+ return a === b;
3252
+ }
3253
+ for (const key of Object.keys(a).filter((key) => keys.includes(key))) {
3254
+ if (!(key in b) || !deepCompareKeys(a[key], b[key], keys)) {
3255
+ return false;
3256
+ }
3257
+ }
3258
+ return true;
3193
3259
  }
3194
3260
  function nodeIsChildOfExpressionStatement(compiler, node) {
3195
3261
  return compiler.isExpressionStatement(node.parent);
@@ -3197,70 +3263,170 @@ function nodeIsChildOfExpressionStatement(compiler, node) {
3197
3263
 
3198
3264
  class AbilityLayer {
3199
3265
  #compiler;
3200
- #expectErrorRegex = /^(\s*)(\/\/ *@ts-expect-error)(!?)(:? *)(.*)?$/gim;
3201
- #filePath = "";
3266
+ #editor;
3202
3267
  #nodes = [];
3203
- #projectService;
3204
- #resolvedConfig;
3205
- #suppressedErrorsMap;
3206
- #text = "";
3207
- constructor(compiler, projectService, resolvedConfig) {
3268
+ constructor(compiler, editor) {
3208
3269
  this.#compiler = compiler;
3209
- this.#projectService = projectService;
3210
- this.#resolvedConfig = resolvedConfig;
3211
- }
3212
- #addRanges(node, ranges) {
3213
- this.#nodes.push(node);
3214
- for (const range of ranges) {
3215
- const rangeText = range.replacement != null
3216
- ? `${range.replacement}${this.#getErasedRangeText(range).slice(range.replacement.length)}`
3217
- : this.#getErasedRangeText(range);
3218
- this.#text = `${this.#text.slice(0, range.start)}${rangeText}${this.#text.slice(range.end)}`;
3219
- }
3270
+ this.#editor = editor;
3220
3271
  }
3221
3272
  #belongsToNode(node, diagnostic) {
3222
3273
  switch (node.brand) {
3223
3274
  case "expect":
3224
- return (diagnosticBelongsToNode(diagnostic, node.matcherNode) &&
3225
- !diagnosticBelongsToNode(diagnostic, node.source));
3275
+ return (diagnosticBelongsToNode(diagnostic, node.matcherNode) ||
3276
+ diagnosticBelongsToNode(diagnostic, node.source));
3226
3277
  case "when":
3227
3278
  return (diagnosticBelongsToNode(diagnostic, node.actionNode) &&
3228
3279
  !diagnosticBelongsToNode(diagnostic, node.target));
3229
3280
  }
3230
3281
  return false;
3231
3282
  }
3283
+ close(diagnostics) {
3284
+ if (diagnostics != null && this.#nodes.length > 0) {
3285
+ this.#nodes.reverse();
3286
+ for (const diagnostic of diagnostics) {
3287
+ this.#mapToNodes(diagnostic);
3288
+ }
3289
+ }
3290
+ this.#nodes = [];
3291
+ }
3232
3292
  #mapToNodes(diagnostic) {
3233
3293
  for (const node of this.#nodes) {
3234
3294
  if (this.#belongsToNode(node, diagnostic)) {
3235
3295
  node.abilityDiagnostics.add(diagnostic);
3236
- return true;
3296
+ break;
3237
3297
  }
3238
3298
  }
3239
- return false;
3240
3299
  }
3241
- #mapToDirectives(diagnostic) {
3242
- if (!isDiagnosticWithLocation(diagnostic)) {
3243
- return;
3244
- }
3245
- const { file, start } = diagnostic;
3246
- const lineMap = file.getLineStarts();
3247
- let line = this.#compiler.getLineAndCharacterOfPosition(file, start).line - 1;
3248
- while (line >= 0) {
3249
- const suppressedError = this.#suppressedErrorsMap?.get(line);
3250
- if (suppressedError != null) {
3251
- suppressedError.diagnostics.push(diagnostic);
3300
+ visitExpect(expect) {
3301
+ const expectStart = expect.node.getStart();
3302
+ const expectExpressionEnd = expect.node.expression.getEnd();
3303
+ const expectEnd = expect.node.getEnd();
3304
+ const matcherNameEnd = expect.matcherNameNode.getEnd();
3305
+ switch (expect.matcherNameNode.name.text) {
3306
+ case "toBeApplicable":
3307
+ this.#nodes.push(expect);
3308
+ this.#editor.replaceRanges([
3309
+ [expectStart, expectExpressionEnd],
3310
+ [expectEnd, matcherNameEnd],
3311
+ ]);
3252
3312
  break;
3253
- }
3254
- const lineText = file.text.slice(lineMap[line], lineMap[line + 1]).trim();
3255
- if (lineText !== "" && !lineText.startsWith("//")) {
3313
+ case "toBeCallableWith":
3314
+ this.#nodes.push(expect);
3315
+ this.#editor.eraseTrailingComma(expect.source);
3316
+ this.#editor.replaceRanges([
3317
+ [
3318
+ expectStart,
3319
+ expectExpressionEnd,
3320
+ nodeIsChildOfExpressionStatement(this.#compiler, expect.matcherNode) ? ";" : "",
3321
+ ],
3322
+ [expectEnd, matcherNameEnd],
3323
+ ]);
3324
+ break;
3325
+ case "toBeConstructableWith":
3326
+ this.#nodes.push(expect);
3327
+ this.#editor.eraseTrailingComma(expect.source);
3328
+ this.#editor.replaceRanges([
3329
+ [
3330
+ expectStart,
3331
+ expectExpressionEnd,
3332
+ nodeIsChildOfExpressionStatement(this.#compiler, expect.matcherNode) ? "; new" : "new",
3333
+ ],
3334
+ [expectEnd, matcherNameEnd],
3335
+ ]);
3256
3336
  break;
3337
+ }
3338
+ }
3339
+ visitWhen(when) {
3340
+ const whenStart = when.node.getStart();
3341
+ const whenExpressionEnd = when.node.expression.getEnd();
3342
+ const whenEnd = when.node.getEnd();
3343
+ const actionNameEnd = when.actionNameNode.getEnd();
3344
+ switch (when.actionNameNode.name.text) {
3345
+ case "isCalledWith":
3346
+ this.#nodes.push(when);
3347
+ this.#editor.eraseTrailingComma(when.target);
3348
+ this.#editor.replaceRanges([
3349
+ [whenStart, whenExpressionEnd, nodeIsChildOfExpressionStatement(this.#compiler, when.actionNode) ? ";" : ""],
3350
+ [whenEnd, actionNameEnd],
3351
+ ]);
3352
+ break;
3353
+ }
3354
+ }
3355
+ }
3356
+
3357
+ class SourceTextEditor {
3358
+ #filePath = "";
3359
+ #sourceFile;
3360
+ #text = "";
3361
+ open(sourceFile) {
3362
+ this.#sourceFile = sourceFile;
3363
+ this.#filePath = sourceFile.fileName;
3364
+ this.#text = sourceFile.text;
3365
+ }
3366
+ close() {
3367
+ if (this.#sourceFile != null) {
3368
+ SourceService.set(this.#sourceFile);
3369
+ this.#sourceFile = undefined;
3370
+ }
3371
+ this.#filePath = "";
3372
+ this.#text = "";
3373
+ }
3374
+ eraseTrailingComma(node) {
3375
+ if (node.hasTrailingComma) {
3376
+ this.replaceRange(node.end - 1, node.end);
3377
+ }
3378
+ }
3379
+ #getErasedRange(start, end) {
3380
+ if (this.#text.indexOf("\n", start) >= end) {
3381
+ return " ".repeat(end - start);
3382
+ }
3383
+ const text = [];
3384
+ for (let index = start; index < end; index++) {
3385
+ const character = this.#text.charAt(index);
3386
+ switch (character) {
3387
+ case "\n":
3388
+ case "\r":
3389
+ text.push(character);
3390
+ break;
3391
+ default:
3392
+ text.push(" ");
3257
3393
  }
3258
- line--;
3259
3394
  }
3395
+ return text.join("");
3396
+ }
3397
+ getFilePath() {
3398
+ return this.#filePath;
3399
+ }
3400
+ getText() {
3401
+ return this.#text;
3402
+ }
3403
+ replaceRange(start, end, replacement) {
3404
+ const rangeText = replacement != null
3405
+ ? `${replacement}${this.#getErasedRange(start, end).slice(replacement.length)}`
3406
+ : this.#getErasedRange(start, end);
3407
+ this.#text = `${this.#text.slice(0, start)}${rangeText}${this.#text.slice(end)}`;
3408
+ }
3409
+ replaceRanges(ranges) {
3410
+ for (const [start, end, replacement] of ranges) {
3411
+ this.replaceRange(start, end, replacement);
3412
+ }
3413
+ }
3414
+ }
3415
+
3416
+ class SuppressedLayer {
3417
+ #compiler;
3418
+ #editor;
3419
+ #expectErrorRegex = /^(\s*)(\/\/ *@ts-expect-error)(!?)(:? *)(.*)?$/gim;
3420
+ #resolvedConfig;
3421
+ #suppressedErrorsMap;
3422
+ constructor(compiler, editor, resolvedConfig) {
3423
+ this.#compiler = compiler;
3424
+ this.#editor = editor;
3425
+ this.#resolvedConfig = resolvedConfig;
3260
3426
  }
3261
- #collectSuppressedErrors() {
3427
+ #collectSuppressedErrors(text) {
3262
3428
  const ranges = [];
3263
- for (const match of this.#text.matchAll(this.#expectErrorRegex)) {
3429
+ for (const match of text.matchAll(this.#expectErrorRegex)) {
3264
3430
  const offsetText = match?.[1];
3265
3431
  const directiveText = match?.[2];
3266
3432
  const ignoreText = match?.[3];
@@ -3283,126 +3449,89 @@ class AbilityLayer {
3283
3449
  }
3284
3450
  return ranges;
3285
3451
  }
3286
- close(testTree) {
3287
- if (this.#nodes.length > 0 || this.#suppressedErrorsMap != null) {
3288
- SourceService.set(testTree.sourceFile);
3289
- this.#projectService.openFile(this.#filePath, this.#text, this.#resolvedConfig.rootPath);
3290
- const languageService = this.#projectService.getLanguageService(this.#filePath);
3291
- const diagnostics = languageService?.getSemanticDiagnostics(this.#filePath);
3292
- if (diagnostics != null) {
3293
- this.#nodes.reverse();
3294
- for (const diagnostic of diagnostics) {
3295
- if (this.#mapToNodes(diagnostic)) {
3296
- continue;
3297
- }
3298
- this.#mapToDirectives(diagnostic);
3299
- }
3452
+ close(diagnostics) {
3453
+ if (diagnostics != null && this.#suppressedErrorsMap != null) {
3454
+ for (const diagnostic of diagnostics) {
3455
+ this.#mapToDirectives(diagnostic);
3300
3456
  }
3301
3457
  }
3302
- this.#filePath = "";
3303
- this.#nodes = [];
3304
3458
  this.#suppressedErrorsMap = undefined;
3305
- this.#text = "";
3306
- }
3307
- #eraseTrailingComma(node, parent) {
3308
- if (node.hasTrailingComma) {
3309
- this.#addRanges(parent, [{ start: node.end - 1, end: node.end }]);
3310
- }
3311
3459
  }
3312
- #getErasedRangeText(range) {
3313
- if (this.#text.indexOf("\n", range.start) >= range.end) {
3314
- return " ".repeat(range.end - range.start);
3315
- }
3316
- const text = [];
3317
- for (let index = range.start; index < range.end; index++) {
3318
- const character = this.#text.charAt(index);
3319
- switch (character) {
3320
- case "\n":
3321
- case "\r":
3322
- text.push(character);
3323
- break;
3324
- default:
3325
- text.push(" ");
3326
- }
3460
+ #mapToDirectives(diagnostic) {
3461
+ if (!isDiagnosticWithLocation(diagnostic)) {
3462
+ return;
3327
3463
  }
3328
- return text.join("");
3329
- }
3330
- handleExpect(expect) {
3331
- const expectStart = expect.node.getStart();
3332
- const expectExpressionEnd = expect.node.expression.getEnd();
3333
- const expectEnd = expect.node.getEnd();
3334
- const matcherNameEnd = expect.matcherNameNode.getEnd();
3335
- switch (expect.matcherNameNode.name.text) {
3336
- case "toBeApplicable":
3337
- this.#addRanges(expect, [
3338
- { start: expectStart, end: expectExpressionEnd },
3339
- { start: expectEnd, end: matcherNameEnd },
3340
- ]);
3341
- break;
3342
- case "toBeCallableWith":
3343
- this.#eraseTrailingComma(expect.source, expect);
3344
- this.#addRanges(expect, [
3345
- {
3346
- start: expectStart,
3347
- end: expectExpressionEnd,
3348
- replacement: nodeIsChildOfExpressionStatement(this.#compiler, expect.matcherNode) ? ";" : "",
3349
- },
3350
- { start: expectEnd, end: matcherNameEnd },
3351
- ]);
3464
+ const { file, start } = diagnostic;
3465
+ const lineMap = file.getLineStarts();
3466
+ let line = this.#compiler.getLineAndCharacterOfPosition(file, start).line - 1;
3467
+ while (line >= 0) {
3468
+ const suppressedError = this.#suppressedErrorsMap?.get(line);
3469
+ if (suppressedError != null) {
3470
+ suppressedError.diagnostics.push(diagnostic);
3352
3471
  break;
3353
- case "toBeConstructableWith":
3354
- this.#eraseTrailingComma(expect.source, expect);
3355
- this.#addRanges(expect, [
3356
- {
3357
- start: expectStart,
3358
- end: expectExpressionEnd,
3359
- replacement: nodeIsChildOfExpressionStatement(this.#compiler, expect.matcherNode) ? "; new" : "new",
3360
- },
3361
- { start: expectEnd, end: matcherNameEnd },
3362
- ]);
3472
+ }
3473
+ const lineText = file.text.slice(lineMap[line], lineMap[line + 1]).trim();
3474
+ if (lineText !== "" && !lineText.startsWith("//")) {
3363
3475
  break;
3476
+ }
3477
+ line--;
3364
3478
  }
3365
3479
  }
3366
- #handleSuppressedErrors(testTree) {
3367
- const suppressedErrors = this.#collectSuppressedErrors();
3480
+ open(tree) {
3481
+ const suppressedErrors = this.#collectSuppressedErrors(this.#editor.getText());
3368
3482
  if (this.#resolvedConfig.checkSuppressedErrors) {
3369
- testTree.suppressedErrors = suppressedErrors;
3483
+ tree.suppressedErrors = suppressedErrors;
3370
3484
  this.#suppressedErrorsMap = new Map();
3371
3485
  }
3372
3486
  for (const suppressedError of suppressedErrors) {
3373
3487
  const { start, end } = suppressedError.directive;
3374
- const rangeText = this.#getErasedRangeText({ start: start + 2, end });
3375
- this.#text = `${this.#text.slice(0, start + 2)}${rangeText}${this.#text.slice(end)}`;
3488
+ this.#editor.replaceRange(start + 2, end);
3376
3489
  if (this.#suppressedErrorsMap != null) {
3377
- const { line } = testTree.sourceFile.getLineAndCharacterOfPosition(start);
3490
+ const { line } = tree.sourceFile.getLineAndCharacterOfPosition(start);
3378
3491
  this.#suppressedErrorsMap.set(line, suppressedError);
3379
3492
  }
3380
3493
  }
3381
3494
  }
3382
- handleWhen(whenNode) {
3383
- const whenStart = whenNode.node.getStart();
3384
- const whenExpressionEnd = whenNode.node.expression.getEnd();
3385
- const whenEnd = whenNode.node.getEnd();
3386
- const actionNameEnd = whenNode.actionNameNode.getEnd();
3387
- switch (whenNode.actionNameNode.name.text) {
3388
- case "isCalledWith":
3389
- this.#eraseTrailingComma(whenNode.target, whenNode);
3390
- this.#addRanges(whenNode, [
3391
- {
3392
- start: whenStart,
3393
- end: whenExpressionEnd,
3394
- replacement: nodeIsChildOfExpressionStatement(this.#compiler, whenNode.actionNode) ? ";" : "",
3395
- },
3396
- { start: whenEnd, end: actionNameEnd },
3397
- ]);
3495
+ }
3496
+
3497
+ class Layers {
3498
+ #abilityLayer;
3499
+ #editor = new SourceTextEditor();
3500
+ #projectService;
3501
+ #suppressedDiagnostics;
3502
+ #suppressedLayer;
3503
+ constructor(compiler, projectService, resolvedConfig) {
3504
+ this.#projectService = projectService;
3505
+ this.#abilityLayer = new AbilityLayer(compiler, this.#editor);
3506
+ this.#suppressedLayer = new SuppressedLayer(compiler, this.#editor, resolvedConfig);
3507
+ }
3508
+ close() {
3509
+ let isSeenDiagnostic;
3510
+ if (this.#suppressedDiagnostics != null) {
3511
+ const seenDiagnostics = this.#suppressedDiagnostics;
3512
+ this.#suppressedDiagnostics = undefined;
3513
+ isSeenDiagnostic = (diagnostic) => !seenDiagnostics.some((seenDiagnostic) => compareDiagnostics(diagnostic, seenDiagnostic));
3514
+ }
3515
+ const abilityDiagnostics = this.#projectService.getDiagnostics(this.#editor.getFilePath(), this.#editor.getText(), isSeenDiagnostic);
3516
+ this.#abilityLayer.close(abilityDiagnostics);
3517
+ this.#editor.close();
3518
+ }
3519
+ open(tree) {
3520
+ this.#editor.open(tree.sourceFile);
3521
+ this.#suppressedLayer.open(tree);
3522
+ this.#suppressedDiagnostics = this.#projectService.getDiagnostics(this.#editor.getFilePath(), this.#editor.getText());
3523
+ this.#suppressedLayer.close(this.#suppressedDiagnostics);
3524
+ }
3525
+ visit(node) {
3526
+ switch (node.brand) {
3527
+ case "expect":
3528
+ this.#abilityLayer.visitExpect(node);
3529
+ break;
3530
+ case "when":
3531
+ this.#abilityLayer.visitWhen(node);
3398
3532
  break;
3399
3533
  }
3400
3534
  }
3401
- open(testTree) {
3402
- this.#filePath = testTree.sourceFile.fileName;
3403
- this.#text = testTree.sourceFile.text;
3404
- this.#handleSuppressedErrors(testTree);
3405
- }
3406
3535
  }
3407
3536
 
3408
3537
  class CollectDiagnosticText {
@@ -3591,12 +3720,12 @@ class WhenNode extends TestTreeNode {
3591
3720
  }
3592
3721
 
3593
3722
  class CollectService {
3594
- #abilityLayer;
3723
+ #layers;
3595
3724
  #compiler;
3596
3725
  #identifierLookup;
3597
3726
  constructor(compiler, projectService, resolvedConfig) {
3598
3727
  this.#compiler = compiler;
3599
- this.#abilityLayer = new AbilityLayer(compiler, projectService, resolvedConfig);
3728
+ this.#layers = new Layers(compiler, projectService, resolvedConfig);
3600
3729
  this.#identifierLookup = new IdentifierLookup(compiler);
3601
3730
  }
3602
3731
  #collectTestTreeNodes(node, parent, testTree) {
@@ -3629,7 +3758,7 @@ class CollectService {
3629
3758
  return;
3630
3759
  }
3631
3760
  const expectNode = new ExpectNode(this.#compiler, meta.brand, node, parent, meta.flags, matcherNode, matcherNameNode, modifierNode, notNode);
3632
- this.#abilityLayer.handleExpect(expectNode);
3761
+ this.#layers.visit(expectNode);
3633
3762
  this.#compiler.forEachChild(node, (node) => {
3634
3763
  this.#collectTestTreeNodes(node, expectNode, testTree);
3635
3764
  });
@@ -3656,7 +3785,7 @@ class CollectService {
3656
3785
  }
3657
3786
  });
3658
3787
  const whenNode = new WhenNode(this.#compiler, meta.brand, node, parent, meta.flags, actionNode, actionNameNode);
3659
- this.#abilityLayer.handleWhen(whenNode);
3788
+ this.#layers.visit(whenNode);
3660
3789
  this.#onNode(whenNode, parent, testTree);
3661
3790
  return;
3662
3791
  }
@@ -3673,10 +3802,10 @@ class CollectService {
3673
3802
  createTestTree(sourceFile, semanticDiagnostics = []) {
3674
3803
  const testTree = new TestTree(new Set(semanticDiagnostics), sourceFile);
3675
3804
  EventEmitter.dispatch(["collect:start", { tree: testTree }]);
3676
- this.#abilityLayer.open(testTree);
3805
+ this.#layers.open(testTree);
3677
3806
  this.#identifierLookup.open();
3678
3807
  this.#collectTestTreeNodes(sourceFile, testTree, testTree);
3679
- this.#abilityLayer.close(testTree);
3808
+ this.#layers.close();
3680
3809
  EventEmitter.dispatch(["collect:end", { tree: testTree }]);
3681
3810
  return testTree;
3682
3811
  }
@@ -3745,6 +3874,10 @@ class CollectService {
3745
3874
  }
3746
3875
  }
3747
3876
 
3877
+ function nodeBelongsToArgumentList(compiler, node) {
3878
+ return compiler.isCallExpression(node.parent) && node.parent.arguments.some((argument) => argument === node);
3879
+ }
3880
+
3748
3881
  var TestTreeNodeBrand;
3749
3882
  (function (TestTreeNodeBrand) {
3750
3883
  TestTreeNodeBrand["Describe"] = "describe";
@@ -3808,6 +3941,7 @@ class ProjectService {
3808
3941
  }
3809
3942
  closeFile(filePath) {
3810
3943
  this.#service.closeClientFile(filePath);
3944
+ SourceService.delete(filePath);
3811
3945
  }
3812
3946
  #getDefaultCompilerOptions() {
3813
3947
  const defaultCompilerOptions = {
@@ -3837,6 +3971,15 @@ class ProjectService {
3837
3971
  }
3838
3972
  return project;
3839
3973
  }
3974
+ getDiagnostics(filePath, sourceText, shouldInclude) {
3975
+ this.openFile(filePath, sourceText);
3976
+ const languageService = this.getLanguageService(filePath);
3977
+ const diagnostics = languageService?.getSemanticDiagnostics(filePath);
3978
+ if (diagnostics != null && shouldInclude != null) {
3979
+ return diagnostics.filter(shouldInclude);
3980
+ }
3981
+ return diagnostics;
3982
+ }
3840
3983
  getLanguageService(filePath) {
3841
3984
  const project = this.getDefaultProject(filePath);
3842
3985
  return project?.getLanguageService(true);
@@ -3846,7 +3989,7 @@ class ProjectService {
3846
3989
  const { fileNames } = this.#compiler.parseJsonSourceFileConfigFileContent(configSourceFile, this.#compiler.sys, Path.dirname(this.#resolvedConfig.tsconfig), undefined, this.#resolvedConfig.tsconfig);
3847
3990
  return fileNames.includes(filePath);
3848
3991
  }
3849
- openFile(filePath, sourceText, projectRootPath) {
3992
+ openFile(filePath, sourceText) {
3850
3993
  switch (this.#resolvedConfig.tsconfig) {
3851
3994
  case "findup":
3852
3995
  break;
@@ -3858,7 +4001,7 @@ class ProjectService {
3858
4001
  ? () => this.#resolvedConfig.tsconfig
3859
4002
  : () => undefined;
3860
4003
  }
3861
- const { configFileErrors, configFileName } = this.#service.openClientFile(filePath, sourceText, undefined, projectRootPath);
4004
+ const { configFileErrors, configFileName } = this.#service.openClientFile(filePath, sourceText, undefined, this.#resolvedConfig.rootPath);
3862
4005
  if (configFileName !== this.#lastSeenProject) {
3863
4006
  this.#lastSeenProject = configFileName;
3864
4007
  EventEmitter.dispatch([
@@ -3926,12 +4069,17 @@ class SuppressedDiagnosticText {
3926
4069
  }
3927
4070
 
3928
4071
  class SuppressedService {
3929
- match(testTree, onDiagnostics) {
4072
+ match(testTree) {
3930
4073
  if (!testTree.suppressedErrors) {
3931
4074
  return;
3932
4075
  }
3933
4076
  for (const suppressedError of testTree.suppressedErrors) {
3934
- if (suppressedError.diagnostics.length === 0 || suppressedError.ignore) {
4077
+ const suppressedResult = new SuppressedResult(suppressedError);
4078
+ if (suppressedError.diagnostics.length === 0) {
4079
+ continue;
4080
+ }
4081
+ if (suppressedError.ignore) {
4082
+ EventEmitter.dispatch(["suppressed:ignore", { result: suppressedResult }]);
3935
4083
  continue;
3936
4084
  }
3937
4085
  const related = [
@@ -3941,12 +4089,12 @@ class SuppressedService {
3941
4089
  const origin = new DiagnosticOrigin(suppressedError.directive.start, suppressedError.directive.end, testTree.sourceFile);
3942
4090
  if (!suppressedError.argument?.text) {
3943
4091
  const text = SuppressedDiagnosticText.directiveRequires();
3944
- onDiagnostics([Diagnostic.error(text, origin).add({ related })]);
4092
+ this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
3945
4093
  continue;
3946
4094
  }
3947
4095
  if (suppressedError.diagnostics.length > 1) {
3948
- const text = [SuppressedDiagnosticText.onlySingleError()];
3949
- onDiagnostics([Diagnostic.error(text, origin).add({ related })]);
4096
+ const text = SuppressedDiagnosticText.onlySingleError();
4097
+ this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
3950
4098
  continue;
3951
4099
  }
3952
4100
  let messageText = getDiagnosticMessageText(suppressedError.diagnostics[0]);
@@ -3954,10 +4102,12 @@ class SuppressedService {
3954
4102
  messageText = messageText.join("\n");
3955
4103
  }
3956
4104
  if (!this.#matchMessage(messageText, suppressedError.argument.text)) {
3957
- const text = [SuppressedDiagnosticText.messageDidNotMatch()];
4105
+ const text = SuppressedDiagnosticText.messageDidNotMatch();
3958
4106
  const origin = new DiagnosticOrigin(suppressedError.argument.start, suppressedError.argument.end, testTree.sourceFile);
3959
- onDiagnostics([Diagnostic.error(text, origin).add({ related })]);
4107
+ this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
4108
+ continue;
3960
4109
  }
4110
+ EventEmitter.dispatch(["suppressed:match", { result: suppressedResult }]);
3961
4111
  }
3962
4112
  }
3963
4113
  #matchMessage(source, target) {
@@ -3973,6 +4123,9 @@ class SuppressedService {
3973
4123
  }
3974
4124
  return source.includes(target);
3975
4125
  }
4126
+ #onDiagnostics(diagnostic, result) {
4127
+ EventEmitter.dispatch(["suppressed:error", { diagnostics: [diagnostic], result }]);
4128
+ }
3976
4129
  }
3977
4130
 
3978
4131
  class EnsureDiagnosticText {
@@ -4075,11 +4228,11 @@ class ExpectDiagnosticText {
4075
4228
  static isNotAssignableTo(sourceTypeText, targetTypeText) {
4076
4229
  return `Type '${sourceTypeText}' is not assignable to type '${targetTypeText}'.`;
4077
4230
  }
4078
- static isAssignableWith(sourceTypeText, targetTypeText) {
4079
- return `Type '${sourceTypeText}' is assignable with type '${targetTypeText}'.`;
4231
+ static isAssignableFrom(sourceTypeText, targetTypeText) {
4232
+ return `Type '${sourceTypeText}' is assignable from type '${targetTypeText}'.`;
4080
4233
  }
4081
- static isNotAssignableWith(sourceTypeText, targetTypeText) {
4082
- return `Type '${sourceTypeText}' is not assignable with type '${targetTypeText}'.`;
4234
+ static isNotAssignableFrom(sourceTypeText, targetTypeText) {
4235
+ return `Type '${sourceTypeText}' is not assignable from type '${targetTypeText}'.`;
4083
4236
  }
4084
4237
  static isTheSame(sourceTypeText, targetTypeText) {
4085
4238
  return `Type '${sourceTypeText}' is the same as type '${targetTypeText}'.`;
@@ -4293,7 +4446,7 @@ class ToAcceptProps {
4293
4446
  }
4294
4447
  if (this.#isOptionalProperty(targetProperty) && !this.#isOptionalProperty(sourceProperty)) {
4295
4448
  const text = [
4296
- ExpectDiagnosticText.isNotAssignableWith(sourceTypeText, targetTypeText),
4449
+ ExpectDiagnosticText.isNotAssignableFrom(sourceTypeText, targetTypeText),
4297
4450
  ExpectDiagnosticText.requiresProperty(sourceTypeText, targetPropertyName),
4298
4451
  ];
4299
4452
  const origin = matchWorker.resolveDiagnosticOrigin(targetProperty, targetNode);
@@ -4306,9 +4459,9 @@ class ToAcceptProps {
4306
4459
  const targetPropertyTypeText = this.#typeChecker.typeToString(targetPropertyType);
4307
4460
  const sourcePropertyTypeText = this.#typeChecker.typeToString(sourcePropertyType);
4308
4461
  const text = [
4309
- ExpectDiagnosticText.isNotAssignableWith(sourceTypeText, targetTypeText),
4462
+ ExpectDiagnosticText.isNotAssignableFrom(sourceTypeText, targetTypeText),
4310
4463
  ExpectDiagnosticText.typesOfPropertyAreNotCompatible(targetPropertyName),
4311
- ExpectDiagnosticText.isNotAssignableWith(sourcePropertyTypeText, targetPropertyTypeText),
4464
+ ExpectDiagnosticText.isNotAssignableFrom(sourcePropertyTypeText, targetPropertyTypeText),
4312
4465
  ];
4313
4466
  const origin = matchWorker.resolveDiagnosticOrigin(targetProperty, targetNode);
4314
4467
  diagnostics.push(diagnostic.extendWith(text, origin));
@@ -4320,7 +4473,7 @@ class ToAcceptProps {
4320
4473
  const targetProperty = targetType.getProperty(sourcePropertyName);
4321
4474
  if (!targetProperty && !this.#isOptionalProperty(sourceProperty)) {
4322
4475
  const text = [
4323
- ExpectDiagnosticText.isNotAssignableWith(sourceTypeText, targetTypeText),
4476
+ ExpectDiagnosticText.isNotAssignableFrom(sourceTypeText, targetTypeText),
4324
4477
  ExpectDiagnosticText.requiresProperty(sourceTypeText, sourcePropertyName),
4325
4478
  ];
4326
4479
  diagnostics.push(diagnostic.extendWith(text));
@@ -4328,7 +4481,7 @@ class ToAcceptProps {
4328
4481
  }
4329
4482
  }
4330
4483
  if (diagnostics.length === 0) {
4331
- const text = ExpectDiagnosticText.isAssignableWith(sourceTypeText, targetTypeText);
4484
+ const text = ExpectDiagnosticText.isAssignableFrom(sourceTypeText, targetTypeText);
4332
4485
  diagnostics.push(diagnostic.extendWith(text));
4333
4486
  return { diagnostics, isMatch: true };
4334
4487
  }
@@ -4338,8 +4491,8 @@ class ToAcceptProps {
4338
4491
  let accumulator = [];
4339
4492
  const isMatch = sourceType.types.some((sourceType) => {
4340
4493
  const text = matchWorker.assertionNode.isNot
4341
- ? ExpectDiagnosticText.isAssignableWith(sourceTypeText, targetTypeText)
4342
- : ExpectDiagnosticText.isNotAssignableWith(sourceTypeText, targetTypeText);
4494
+ ? ExpectDiagnosticText.isAssignableFrom(sourceTypeText, targetTypeText)
4495
+ : ExpectDiagnosticText.isNotAssignableFrom(sourceTypeText, targetTypeText);
4343
4496
  const { diagnostics, isMatch } = explain(sourceType, targetType, diagnostic.extendWith(text));
4344
4497
  if (isMatch) {
4345
4498
  accumulator = diagnostics;
@@ -4480,24 +4633,24 @@ class ToBeApplicable {
4480
4633
  }
4481
4634
  }
4482
4635
 
4483
- class ToBeAssignableTo extends RelationMatcherBase {
4484
- explainText = ExpectDiagnosticText.isAssignableTo;
4485
- explainNotText = ExpectDiagnosticText.isNotAssignableTo;
4636
+ class ToBeAssignableFrom extends RelationMatcherBase {
4637
+ explainText = ExpectDiagnosticText.isAssignableFrom;
4638
+ explainNotText = ExpectDiagnosticText.isNotAssignableFrom;
4486
4639
  match(matchWorker, sourceNode, targetNode) {
4487
4640
  return {
4488
4641
  explain: () => this.explain(matchWorker, sourceNode, targetNode),
4489
- isMatch: matchWorker.checkIsAssignableTo(sourceNode, targetNode),
4642
+ isMatch: matchWorker.checkIsAssignableWith(sourceNode, targetNode),
4490
4643
  };
4491
4644
  }
4492
4645
  }
4493
4646
 
4494
- class ToBeAssignableWith extends RelationMatcherBase {
4495
- explainText = ExpectDiagnosticText.isAssignableWith;
4496
- explainNotText = ExpectDiagnosticText.isNotAssignableWith;
4647
+ class ToBeAssignableTo extends RelationMatcherBase {
4648
+ explainText = ExpectDiagnosticText.isAssignableTo;
4649
+ explainNotText = ExpectDiagnosticText.isNotAssignableTo;
4497
4650
  match(matchWorker, sourceNode, targetNode) {
4498
4651
  return {
4499
4652
  explain: () => this.explain(matchWorker, sourceNode, targetNode),
4500
- isMatch: matchWorker.checkIsAssignableWith(sourceNode, targetNode),
4653
+ isMatch: matchWorker.checkIsAssignableTo(sourceNode, targetNode),
4501
4654
  };
4502
4655
  }
4503
4656
  }
@@ -4768,8 +4921,8 @@ class ExpectService {
4768
4921
  toAcceptProps;
4769
4922
  toBe;
4770
4923
  toBeApplicable;
4924
+ toBeAssignableFrom;
4771
4925
  toBeAssignableTo;
4772
- toBeAssignableWith;
4773
4926
  toBeCallableWith;
4774
4927
  toBeConstructableWith;
4775
4928
  toHaveProperty;
@@ -4781,8 +4934,8 @@ class ExpectService {
4781
4934
  this.toAcceptProps = new ToAcceptProps(compiler, typeChecker);
4782
4935
  this.toBe = new ToBe();
4783
4936
  this.toBeApplicable = new ToBeApplicable(compiler);
4937
+ this.toBeAssignableFrom = new ToBeAssignableFrom();
4784
4938
  this.toBeAssignableTo = new ToBeAssignableTo();
4785
- this.toBeAssignableWith = new ToBeAssignableWith();
4786
4939
  this.toBeCallableWith = new ToBeCallableWith(compiler);
4787
4940
  this.toBeConstructableWith = new ToBeConstructableWith(compiler);
4788
4941
  this.toHaveProperty = new ToHaveProperty(compiler);
@@ -4804,8 +4957,8 @@ class ExpectService {
4804
4957
  switch (matcherNameText) {
4805
4958
  case "toAcceptProps":
4806
4959
  case "toBe":
4960
+ case "toBeAssignableFrom":
4807
4961
  case "toBeAssignableTo":
4808
- case "toBeAssignableWith":
4809
4962
  if (!argumentOrTypeArgumentIsProvided("target", "Target", assertionNode.target?.[0], assertionNode.matcherNameNode.name, onDiagnostics)) {
4810
4963
  return;
4811
4964
  }
@@ -5162,7 +5315,7 @@ class TestTreeWalker {
5162
5315
  EventEmitter.dispatch(["test:skip", { result: testResult }]);
5163
5316
  return;
5164
5317
  }
5165
- const isPass = testResult.expectCount.failed === 0;
5318
+ const isPass = testResult.assertionCounts.failed === 0;
5166
5319
  if (FixmeService.isFixme(test, isPass)) {
5167
5320
  EventEmitter.dispatch(["test:fixme", { result: testResult }]);
5168
5321
  return;
@@ -5198,7 +5351,7 @@ class FileRunner {
5198
5351
  if (cancellationToken.isCancellationRequested) {
5199
5352
  return;
5200
5353
  }
5201
- this.#projectService.openFile(file.path, undefined, this.#resolvedConfig.rootPath);
5354
+ this.#projectService.openFile(file.path);
5202
5355
  const fileResult = new FileResult(file);
5203
5356
  EventEmitter.dispatch(["file:start", { result: fileResult }]);
5204
5357
  await this.#run(file, fileResult, cancellationToken);
@@ -5235,13 +5388,11 @@ class FileRunner {
5235
5388
  this.#onDiagnostics([Diagnostic.error("A template test file must export a string.")], fileResult);
5236
5389
  return;
5237
5390
  }
5238
- this.#projectService.openFile(file.path, testText, this.#resolvedConfig.rootPath);
5391
+ this.#projectService.openFile(file.path, testText);
5239
5392
  return this.#resolveFileFacts(file, fileResult, runModeFlags);
5240
5393
  }
5241
5394
  const testTree = this.#collectService.createTestTree(sourceFile, semanticDiagnostics);
5242
- this.#suppressedService.match(testTree, (diagnostics) => {
5243
- this.#onDiagnostics(diagnostics, fileResult);
5244
- });
5395
+ this.#suppressedService.match(testTree);
5245
5396
  return { runModeFlags, testTree, typeChecker };
5246
5397
  }
5247
5398
  async #run(file, fileResult, cancellationToken) {
@@ -5272,7 +5423,7 @@ class FileRunner {
5272
5423
  class Runner {
5273
5424
  #eventEmitter = new EventEmitter();
5274
5425
  #resolvedConfig;
5275
- static version = "5.0.0-beta.0";
5426
+ static version = "5.0.0-beta.1";
5276
5427
  constructor(resolvedConfig) {
5277
5428
  this.#resolvedConfig = resolvedConfig;
5278
5429
  }
@@ -5472,4 +5623,4 @@ class Cli {
5472
5623
  }
5473
5624
  }
5474
5625
 
5475
- export { BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExitCodeHandler, ExpectNode, ExpectResult, ExpectService, FileLocation, FileResult, FileWatcher, Glob, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Reject, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, SourceFile, SourceService, Store, SummaryReporter, SuppressedService, TargetResult, TestResult, TestTree, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, WhenNode, WhenService, addsPackageText, argumentIsProvided, argumentOrTypeArgumentIsProvided, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileStatusText, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, nodeBelongsToArgumentList, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
5626
+ export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, Result, ResultStatus, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, Store, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileStatusText, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };