tstyche 4.0.0-beta.5 → 4.0.0-beta.7
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 +6 -9
- package/build/index.cjs +1 -0
- package/build/index.d.cts +25 -1
- package/build/index.d.ts +25 -1
- package/build/index.js +1 -1
- package/build/tstyche.d.ts +21 -16
- package/build/tstyche.js +974 -864
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -18,18 +18,15 @@ If you are used to test JavaScript, a simple type test file should look familiar
|
|
|
18
18
|
```ts
|
|
19
19
|
import { expect, test } from "tstyche";
|
|
20
20
|
|
|
21
|
-
function
|
|
22
|
-
return a.length
|
|
21
|
+
function isSameLength<T extends { length: number }>(a: T, b: T) {
|
|
22
|
+
return a.length === b.length;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
test("
|
|
26
|
-
expect(
|
|
27
|
-
expect(
|
|
25
|
+
test("isSameLength", () => {
|
|
26
|
+
expect(isSameLength([1, 2], [1, 2, 3])).type.toBe<boolean>();
|
|
27
|
+
expect(isSameLength("one", "two")).type.toBe<boolean>();
|
|
28
28
|
|
|
29
|
-
expect(
|
|
30
|
-
|
|
31
|
-
expect(pickLonger).type.not.toBeCallableWith("zero", [123]);
|
|
32
|
-
expect(pickLonger<string | Array<number>>).type.toBeCallableWith("zero", [123]);
|
|
29
|
+
expect(isSameLength).type.not.toBeCallableWith(1, 2);
|
|
33
30
|
});
|
|
34
31
|
```
|
|
35
32
|
|
package/build/index.cjs
CHANGED
package/build/index.d.cts
CHANGED
|
@@ -269,5 +269,29 @@ declare const test: Test;
|
|
|
269
269
|
* Defines a single test.
|
|
270
270
|
*/
|
|
271
271
|
declare const it: Test;
|
|
272
|
+
interface Actions {
|
|
273
|
+
/**
|
|
274
|
+
* Calls the given function with the provided arguments.
|
|
275
|
+
*/
|
|
276
|
+
isCalledWith: (...args: Array<unknown>) => void;
|
|
277
|
+
}
|
|
278
|
+
interface When {
|
|
279
|
+
/**
|
|
280
|
+
* Creates a test plan.
|
|
281
|
+
*
|
|
282
|
+
* @template Target - The type upon which an action is performed.
|
|
283
|
+
*/
|
|
284
|
+
<Target>(): Actions;
|
|
285
|
+
/**
|
|
286
|
+
* Creates a test plan.
|
|
287
|
+
*
|
|
288
|
+
* @param target - The expression upon which an action is performed.
|
|
289
|
+
*/
|
|
290
|
+
(target: unknown): Actions;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Creates a test plan.
|
|
294
|
+
*/
|
|
295
|
+
declare const when: When;
|
|
272
296
|
|
|
273
|
-
export { describe, expect, it, omit, pick, test };
|
|
297
|
+
export { describe, expect, it, omit, pick, test, when };
|
package/build/index.d.ts
CHANGED
|
@@ -269,5 +269,29 @@ declare const test: Test;
|
|
|
269
269
|
* Defines a single test.
|
|
270
270
|
*/
|
|
271
271
|
declare const it: Test;
|
|
272
|
+
interface Actions {
|
|
273
|
+
/**
|
|
274
|
+
* Calls the given function with the provided arguments.
|
|
275
|
+
*/
|
|
276
|
+
isCalledWith: (...args: Array<unknown>) => void;
|
|
277
|
+
}
|
|
278
|
+
interface When {
|
|
279
|
+
/**
|
|
280
|
+
* Creates a test plan.
|
|
281
|
+
*
|
|
282
|
+
* @template Target - The type upon which an action is performed.
|
|
283
|
+
*/
|
|
284
|
+
<Target>(): Actions;
|
|
285
|
+
/**
|
|
286
|
+
* Creates a test plan.
|
|
287
|
+
*
|
|
288
|
+
* @param target - The expression upon which an action is performed.
|
|
289
|
+
*/
|
|
290
|
+
(target: unknown): Actions;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Creates a test plan.
|
|
294
|
+
*/
|
|
295
|
+
declare const when: When;
|
|
272
296
|
|
|
273
|
-
export { describe, expect, it, omit, pick, test };
|
|
297
|
+
export { describe, expect, it, omit, pick, test, when };
|
package/build/index.js
CHANGED
|
@@ -9,4 +9,4 @@ const noopChain = new Proxy(doNothing, {
|
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
export { noopChain as describe, noopChain as expect, noopChain as it, doNothing as omit, doNothing as pick, noopChain as test };
|
|
12
|
+
export { noopChain as describe, noopChain as expect, noopChain as it, doNothing as omit, doNothing as pick, noopChain as test, noopChain as when };
|
package/build/tstyche.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type ts from 'typescript';
|
|
|
3
3
|
declare enum CancellationReason {
|
|
4
4
|
ConfigChange = "configChange",
|
|
5
5
|
ConfigError = "configError",
|
|
6
|
+
CollectError = "collectError",
|
|
6
7
|
FailFast = "failFast",
|
|
7
8
|
WatchClose = "watchClose"
|
|
8
9
|
}
|
|
@@ -75,7 +76,8 @@ type DiagnosticsHandler<T extends Diagnostic | Array<Diagnostic> = Diagnostic> =
|
|
|
75
76
|
declare enum TestTreeNodeBrand {
|
|
76
77
|
Describe = "describe",
|
|
77
78
|
Test = "test",
|
|
78
|
-
Expect = "expect"
|
|
79
|
+
Expect = "expect",
|
|
80
|
+
When = "when"
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
declare enum TestTreeNodeFlags {
|
|
@@ -342,6 +344,16 @@ declare class CollectService {
|
|
|
342
344
|
createTestTree(sourceFile: ts.SourceFile, semanticDiagnostics?: Array<ts.Diagnostic>): TestTree;
|
|
343
345
|
}
|
|
344
346
|
|
|
347
|
+
declare function nodeBelongsToArgumentList(compiler: typeof ts, node: ts.Node): boolean;
|
|
348
|
+
|
|
349
|
+
declare class WhenNode extends TestTreeNode {
|
|
350
|
+
actionNode: ts.CallExpression;
|
|
351
|
+
actionNameNode: ts.PropertyAccessExpression;
|
|
352
|
+
abilityDiagnostics: Set<ts.Diagnostic> | undefined;
|
|
353
|
+
target: ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
|
|
354
|
+
constructor(compiler: typeof ts, brand: TestTreeNodeBrand, node: ts.CallExpression, parent: TestTree | TestTreeNode, flags: TestTreeNodeFlags, actionNode: ts.CallExpression, actionNameNode: ts.PropertyAccessExpression);
|
|
355
|
+
}
|
|
356
|
+
|
|
345
357
|
interface EnvironmentOptions {
|
|
346
358
|
/**
|
|
347
359
|
* Is `true` if the process is running in continuous integration environment.
|
|
@@ -493,13 +505,12 @@ declare class TargetResult {
|
|
|
493
505
|
declare class Result {
|
|
494
506
|
expectCount: ResultCount;
|
|
495
507
|
fileCount: ResultCount;
|
|
496
|
-
resolvedConfig: ResolvedConfig;
|
|
497
508
|
results: Array<TargetResult>;
|
|
498
509
|
targetCount: ResultCount;
|
|
499
510
|
tasks: Array<Task>;
|
|
500
511
|
testCount: ResultCount;
|
|
501
512
|
timing: ResultTiming;
|
|
502
|
-
constructor(
|
|
513
|
+
constructor(tasks: Array<Task>);
|
|
503
514
|
}
|
|
504
515
|
|
|
505
516
|
interface EventHandler {
|
|
@@ -535,11 +546,13 @@ type Event = ["config:error", {
|
|
|
535
546
|
}] | ["task:end", {
|
|
536
547
|
result: TaskResult;
|
|
537
548
|
}] | ["collect:start", {
|
|
538
|
-
|
|
549
|
+
tree: TestTree;
|
|
550
|
+
}] | ["collect:error", {
|
|
551
|
+
diagnostics: Array<Diagnostic>;
|
|
539
552
|
}] | ["collect:node", {
|
|
540
|
-
|
|
553
|
+
node: TestTreeNode | AssertionNode | WhenNode;
|
|
541
554
|
}] | ["collect:end", {
|
|
542
|
-
|
|
555
|
+
tree: TestTree;
|
|
543
556
|
}] | ["describe:start", {
|
|
544
557
|
result: DescribeResult;
|
|
545
558
|
}] | ["describe:end", {
|
|
@@ -632,11 +645,6 @@ declare class ResultHandler implements EventHandler {
|
|
|
632
645
|
on([event, payload]: Event): void;
|
|
633
646
|
}
|
|
634
647
|
|
|
635
|
-
declare class TestTreeHandler implements EventHandler {
|
|
636
|
-
testTree: TestTree | undefined;
|
|
637
|
-
on([event, payload]: Event): void;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
648
|
type InputHandler = (chunk: string) => void;
|
|
641
649
|
declare class InputService {
|
|
642
650
|
#private;
|
|
@@ -727,13 +735,10 @@ declare class OutputService {
|
|
|
727
735
|
static writeWarning(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
|
|
728
736
|
}
|
|
729
737
|
|
|
730
|
-
declare function summaryText({ duration, expectCount, fileCount,
|
|
738
|
+
declare function summaryText({ duration, expectCount, fileCount, targetCount, testCount, }: {
|
|
731
739
|
duration: number;
|
|
732
740
|
expectCount: ResultCount;
|
|
733
741
|
fileCount: ResultCount;
|
|
734
|
-
onlyMatch: string | undefined;
|
|
735
|
-
pathMatch: Array<string>;
|
|
736
|
-
skipMatch: string | undefined;
|
|
737
742
|
targetCount: ResultCount;
|
|
738
743
|
testCount: ResultCount;
|
|
739
744
|
}): ScribblerJsx.Element;
|
|
@@ -873,5 +878,5 @@ declare class WatchService {
|
|
|
873
878
|
watch(cancellationToken: CancellationToken): AsyncIterable<Array<Task>>;
|
|
874
879
|
}
|
|
875
880
|
|
|
876
|
-
export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, Task, TaskResult, TestResult, TestTree,
|
|
881
|
+
export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, Task, TaskResult, TestResult, TestTree, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, WhenNode, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, nodeBelongsToArgumentList, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
|
877
882
|
export type { CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, EnvironmentOptions, Event, EventHandler, FileWatchHandler, InputHandler, ItemDefinition, MatchResult, OptionDefinition, Plugin, Reporter, ReporterEvent, ResolvedConfig, ScribblerOptions, SelectHookContext, TargetResultStatus, TaskResultStatus, TypeChecker, WatchHandler, WatcherOptions };
|