tstyche 7.0.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,14 +30,14 @@ test("isSameLength", () => {
30
30
  });
31
31
  ```
32
32
 
33
- To group and organize tests, TSTyche has:
33
+ TSTyche lets you organize tests using:
34
34
 
35
- - `test()`, `it()` and `describe()` helpers,
36
- - with `.only`, `.skip` and `.todo` run mode flags.
35
+ - helpers: `test()`, `it()` and `describe()`
36
+ - run mode flags: `.only`, `.skip` and `.todo`
37
37
 
38
38
  ## Assertions
39
39
 
40
- The `expect` style assertions can check either the inferred type of an expression (as in the example above) or a type directly:
40
+ The `expect` style assertions can check either the inferred type of an expression or a type directly:
41
41
 
42
42
  ```ts
43
43
  import { type _, expect } from "tstyche";
@@ -58,32 +58,32 @@ expect<WithLoading<_>>().type.not.toBeInstantiableWith<[string]>();
58
58
 
59
59
  Relation matchers:
60
60
 
61
- - `.toBe()` checks if a type is the same as the given type,
62
- - `.toBeAssignableFrom()` checks if a type is assignable from the given type,
63
- - `.toBeAssignableTo()` checks if a type is assignable to the given type.
61
+ - `.toBe()` checks if a type is the same as the given type
62
+ - `.toBeAssignableFrom()` checks if a type is assignable from the given type
63
+ - `.toBeAssignableTo()` checks if a type is assignable to the given type
64
64
 
65
65
  Ability matchers:
66
66
 
67
- - `.toAcceptProps()` checks if a JSX component accepts the given props,
68
- - `.toBeApplicable` checks if a decorator is applicable to the given class or class member,
69
- - `.toBeCallableWith()` checks if a function is callable with the given arguments,
70
- - `.toBeConstructableWith()` checks if a class is constructable with the given arguments,
71
- - `.toBeInstantiableWith()` checks if a generic is instantiable with the given type arguments,
72
- - `.toHaveProperty()` checks if a type has the given property.
67
+ - `.toAcceptProps()` checks if a JSX component accepts the given props
68
+ - `.toBeApplicable` checks if a decorator is applicable to the given class or class member
69
+ - `.toBeCallableWith()` checks if a function is callable with the given arguments
70
+ - `.toBeConstructableWith()` checks if a class is constructable with the given arguments
71
+ - `.toBeInstantiableWith()` checks if a generic is instantiable with the given type arguments
72
+ - `.toHaveProperty()` checks if a type has the given property
73
73
 
74
74
  ## Runner
75
75
 
76
- The `tstyche` command is the heart of TSTyche. It allows you to select test files by path, filter tests by name and run them against specific versions of TypeScript:
76
+ The `tstyche` command is the heart of TSTyche. It lets you select test files by path, filter tests by name and run them against specific versions of TypeScript:
77
77
 
78
78
  ```shell
79
79
  tstyche query-params --only multiple --target '>=5.6'
80
80
  ```
81
81
 
82
- It is that simple! Actually, TSTyche does even more:
82
+ That is just the beginning. It even lets you:
83
83
 
84
- - checks messages of errors suppressed by `@ts-expect-error` directives,
85
- - generates type tests from a data table,
86
- - runs tests in watch mode.
84
+ - check messages of errors suppressed by `@ts-expect-error` directives
85
+ - generate type tests from a template file
86
+ - run tests in watch mode
87
87
 
88
88
  ## Try It Out
89
89
 
@@ -95,6 +95,10 @@ Try TSTyche online on StackBlitz:
95
95
 
96
96
  Visit [tstyche.org](https://tstyche.org) to view the full documentation.
97
97
 
98
+ ## Roadmap
99
+
100
+ See [ROADMAP.md](https://github.com/tstyche/tstyche/blob/main/ROADMAP.md) for planned features.
101
+
98
102
  ## License
99
103
 
100
104
  [MIT][license-url] © TSTyche
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type ts from 'typescript';
1
+ import ts from 'typescript';
2
2
 
3
3
  declare enum CancellationReason {
4
4
  ConfigChange = "configChange",
@@ -36,8 +36,7 @@ declare enum TestTreeNodeBrand {
36
36
  Describe = "describe",
37
37
  Test = "test",
38
38
  It = "it",
39
- Expect = "expect",
40
- When = "when"
39
+ Expect = "expect"
41
40
  }
42
41
 
43
42
  declare enum TestTreeNodeFlags {
@@ -47,17 +46,9 @@ declare enum TestTreeNodeFlags {
47
46
  Todo = 4
48
47
  }
49
48
 
50
- declare class WhenNode extends TestTreeNode {
51
- actionNode: ts.CallExpression;
52
- actionNameNode: ts.PropertyAccessExpression;
53
- abilityDiagnostics: Set<ts.Diagnostic>;
54
- target: ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
55
- constructor(compiler: typeof ts, brand: TestTreeNodeBrand, node: ts.CallExpression, parent: TestTree | TestTreeNode, flags: TestTreeNodeFlags, actionNode: ts.CallExpression, actionNameNode: ts.PropertyAccessExpression);
56
- }
57
-
58
49
  declare class TestTreeNode {
59
50
  brand: TestTreeNodeBrand;
60
- children: Array<TestTreeNode | ExpectNode | WhenNode>;
51
+ children: Array<TestTreeNode | ExpectNode>;
61
52
  diagnostics: Set<ts.Diagnostic>;
62
53
  flags: TestTreeNodeFlags;
63
54
  name: string;
@@ -79,7 +70,7 @@ declare class ExpectNode extends TestTreeNode {
79
70
  }
80
71
 
81
72
  declare class TestTree {
82
- children: Array<TestTreeNode | ExpectNode | WhenNode>;
73
+ children: Array<TestTreeNode | ExpectNode>;
83
74
  diagnostics: Set<ts.Diagnostic>;
84
75
  hasOnly: boolean;
85
76
  sourceFile: ts.SourceFile;
@@ -93,9 +84,9 @@ declare class DiagnosticOrigin {
93
84
  sourceFile: ts.SourceFile | JsonSourceFile;
94
85
  start: number;
95
86
  constructor(start: number, end: number, sourceFile: ts.SourceFile | JsonSourceFile, assertionNode?: ExpectNode);
87
+ static fromAbilityDiagnostic(diagnostic: ts.DiagnosticWithLocation, assertionNode: ExpectNode): DiagnosticOrigin;
96
88
  static fromAssertion(assertionNode: ExpectNode): DiagnosticOrigin;
97
89
  static fromNode(node: ts.Node, assertionNode?: ExpectNode): DiagnosticOrigin;
98
- static fromNodes(nodes: ts.NodeArray<ts.Node>, assertionNode?: ExpectNode): DiagnosticOrigin;
99
90
  }
100
91
 
101
92
  declare class Diagnostic {
@@ -115,12 +106,27 @@ declare class Diagnostic {
115
106
  static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
116
107
  }
117
108
 
109
+ type DiagnosticsHandler<T extends Diagnostic | Array<Diagnostic> = Diagnostic> = (this: void, diagnostics: T) => void;
110
+ interface Offset {
111
+ position: number;
112
+ diff: number;
113
+ }
114
+
118
115
  declare function diagnosticBelongsToNode(diagnostic: ts.Diagnostic, node: ts.NodeArray<ts.Node> | ts.Node): boolean;
119
116
  declare function getDiagnosticMessageText(diagnostic: ts.Diagnostic): string | Array<string>;
120
117
  declare function getTextSpanEnd(span: ts.TextSpan): number;
121
118
  declare function isDiagnosticWithLocation(diagnostic: ts.Diagnostic): diagnostic is ts.DiagnosticWithLocation;
122
119
 
123
- type DiagnosticsHandler<T extends Diagnostic | Array<Diagnostic> = Diagnostic> = (this: void, diagnostics: T) => void;
120
+ declare class MappedDiagnostic {
121
+ category: ts.DiagnosticCategory;
122
+ code: number;
123
+ file: ts.SourceFile;
124
+ length: number | undefined;
125
+ messageText: string | ts.DiagnosticMessageChain;
126
+ relatedInformation?: Array<ts.DiagnosticRelatedInformation>;
127
+ start: number | undefined;
128
+ constructor(sourceFile: ts.SourceFile, diagnostic: ts.Diagnostic, offsets?: Array<Offset>);
129
+ }
124
130
 
125
131
  declare class JsonSourceFile {
126
132
  #private;
@@ -282,12 +288,13 @@ declare class Options {
282
288
  }
283
289
 
284
290
  interface EnvironmentOptions {
291
+ fetchRetries: number;
292
+ fetchTimeout: number;
285
293
  isCi: boolean;
286
294
  noColor: boolean;
287
295
  noInteractive: boolean;
288
296
  npmRegistry: string;
289
297
  storePath: string;
290
- timeout: number;
291
298
  typescriptModule: string | undefined;
292
299
  }
293
300
 
@@ -451,9 +458,6 @@ declare class SuppressedResult {
451
458
  constructor(suppressed: SuppressedError);
452
459
  }
453
460
 
454
- interface EventHandler {
455
- on: (event: Event) => void;
456
- }
457
461
  type Event = ["config:error", {
458
462
  diagnostics: Array<Diagnostic>;
459
463
  }] | ["select:error", {
@@ -490,7 +494,7 @@ type Event = ["config:error", {
490
494
  }] | ["collect:error", {
491
495
  diagnostics: Array<Diagnostic>;
492
496
  }] | ["collect:node", {
493
- node: TestTreeNode | ExpectNode | WhenNode;
497
+ node: TestTreeNode | ExpectNode;
494
498
  }] | ["collect:end", {
495
499
  tree: TestTree;
496
500
  }] | ["describe:start", {
@@ -536,6 +540,9 @@ type Event = ["config:error", {
536
540
  }] | ["watch:error", {
537
541
  diagnostics: Array<Diagnostic>;
538
542
  }];
543
+ interface EventHandler {
544
+ on: (event: Event) => void;
545
+ }
539
546
 
540
547
  declare class EventEmitter {
541
548
  #private;
@@ -750,5 +757,5 @@ declare class Version {
750
757
  static isSatisfiedWith(source: string, target: string): boolean;
751
758
  }
752
759
 
753
- export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, DotReporter, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectConfigKind, ProjectResult, Result, ResultStatus, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, dotText, environmentOptions, fileStatusText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesText, waitingForFileChangesText, watchUsageText };
754
- export type { AssertionCounts, AssertionResultStatus, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, OptionDefinition, ProjectConfig, Reporter, ReporterEvent, ResolvedConfig, ResultCounts, ResultTiming, ScribblerOptions, SuppressedCounts, SuppressedResultStatus, TargetCounts, TargetResultStatus, TestCounts, TestResultStatus, TextRange, WriteStream };
760
+ export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, DotReporter, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, MappedDiagnostic, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectConfigKind, ProjectResult, Result, ResultStatus, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, dotText, environmentOptions, fileStatusText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesText, waitingForFileChangesText, watchUsageText };
761
+ export type { AssertionCounts, AssertionResultStatus, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, Offset, OptionDefinition, ProjectConfig, Reporter, ReporterEvent, ResolvedConfig, ResultCounts, ResultTiming, ScribblerOptions, SuppressedCounts, SuppressedResultStatus, TargetCounts, TargetResultStatus, TestCounts, TestResultStatus, TextRange, WriteStream };