tstyche 7.2.5 → 8.0.0-beta.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 +4 -0
- package/dist/api.d.ts +16 -761
- package/dist/api.js +16 -6204
- package/dist/bin.js +2 -3
- package/dist/checker/BaseCheckerAdapter.d.ts +15 -0
- package/dist/checker/BaseCheckerAdapter.js +32 -0
- package/dist/checker/CompatCheckerAdapter.d.ts +70 -0
- package/dist/checker/CompatCheckerAdapter.js +221 -0
- package/dist/checker/NativeCheckerAdapter.d.ts +70 -0
- package/dist/checker/NativeCheckerAdapter.js +200 -0
- package/dist/checker/index.d.ts +3 -0
- package/dist/checker/index.js +2 -0
- package/dist/checker/types.d.ts +9 -0
- package/dist/checker/types.js +1 -0
- package/dist/cli/Cli.d.ts +5 -0
- package/dist/cli/Cli.js +144 -0
- package/dist/cli/CliDIagnosticText.d.ts +3 -0
- package/dist/cli/CliDIagnosticText.js +9 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/collect/CollectDiagnosticText.d.ts +3 -0
- package/dist/collect/CollectDiagnosticText.js +5 -0
- package/dist/collect/CollectService.d.ts +9 -0
- package/dist/collect/CollectService.js +150 -0
- package/dist/collect/ExpectNode.d.ts +16 -0
- package/dist/collect/ExpectNode.js +30 -0
- package/dist/collect/IdentifierLookup.d.ts +18 -0
- package/dist/collect/IdentifierLookup.js +90 -0
- package/dist/collect/TestTree.d.ts +16 -0
- package/dist/collect/TestTree.js +15 -0
- package/dist/collect/TestTreeNode.d.ts +15 -0
- package/dist/collect/TestTreeNode.js +27 -0
- package/dist/collect/TestTreeNodeBrand.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeBrand.enum.js +7 -0
- package/dist/collect/TestTreeNodeFlags.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeFlags.enum.js +7 -0
- package/dist/collect/index.d.ts +6 -0
- package/dist/collect/index.js +6 -0
- package/dist/config/CommandParser.d.ts +7 -0
- package/dist/config/CommandParser.js +107 -0
- package/dist/config/Config.d.ts +18 -0
- package/dist/config/Config.js +59 -0
- package/dist/config/ConfigDiagnosticText.d.ts +19 -0
- package/dist/config/ConfigDiagnosticText.js +57 -0
- package/dist/config/ConfigParser.d.ts +10 -0
- package/dist/config/ConfigParser.js +165 -0
- package/dist/config/Directive.d.ts +9 -0
- package/dist/config/Directive.js +119 -0
- package/dist/config/DirectiveDiagnosticText.d.ts +5 -0
- package/dist/config/DirectiveDiagnosticText.js +11 -0
- package/dist/config/OptionBrand.enum.d.ts +8 -0
- package/dist/config/OptionBrand.enum.js +9 -0
- package/dist/config/OptionGroup.enum.d.ts +5 -0
- package/dist/config/OptionGroup.enum.js +6 -0
- package/dist/config/Options.d.ts +29 -0
- package/dist/config/Options.js +290 -0
- package/dist/config/Target.d.ts +7 -0
- package/dist/config/Target.js +47 -0
- package/dist/config/defaultOptions.d.ts +2 -0
- package/dist/config/defaultOptions.js +14 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +7 -0
- package/dist/config/types.d.ts +55 -0
- package/dist/config/types.js +1 -0
- package/dist/diagnostic/Diagnostic.d.ts +19 -0
- package/dist/diagnostic/Diagnostic.js +51 -0
- package/dist/diagnostic/DiagnosticCategory.enum.d.ts +4 -0
- package/dist/diagnostic/DiagnosticCategory.enum.js +5 -0
- package/dist/diagnostic/DiagnosticOrigin.d.ts +13 -0
- package/dist/diagnostic/DiagnosticOrigin.js +27 -0
- package/dist/diagnostic/helpers.d.ts +6 -0
- package/dist/diagnostic/helpers.js +74 -0
- package/dist/diagnostic/index.d.ts +5 -0
- package/dist/diagnostic/index.js +4 -0
- package/dist/diagnostic/types.d.ts +2 -0
- package/dist/diagnostic/types.js +1 -0
- package/dist/editor/TextEditor.d.ts +15 -0
- package/dist/editor/TextEditor.js +88 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/editor/types.d.ts +4 -0
- package/dist/editor/types.js +1 -0
- package/dist/environment/Environment.d.ts +5 -0
- package/dist/environment/Environment.js +89 -0
- package/dist/environment/environmentOptions.d.ts +1 -0
- package/dist/environment/environmentOptions.js +2 -0
- package/dist/environment/index.d.ts +2 -0
- package/dist/environment/index.js +1 -0
- package/dist/environment/types.d.ts +10 -0
- package/dist/environment/types.js +1 -0
- package/dist/events/EventEmitter.d.ts +14 -0
- package/dist/events/EventEmitter.js +42 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +1 -0
- package/dist/events/types.d.ts +88 -0
- package/dist/events/types.js +1 -0
- package/dist/expect/AbilityMatcherBase.d.ts +16 -0
- package/dist/expect/AbilityMatcherBase.js +52 -0
- package/dist/expect/Ensure.d.ts +10 -0
- package/dist/expect/Ensure.js +51 -0
- package/dist/expect/ExpectDiagnosticText.d.ts +29 -0
- package/dist/expect/ExpectDiagnosticText.js +87 -0
- package/dist/expect/ExpectService.d.ts +21 -0
- package/dist/expect/ExpectService.js +90 -0
- package/dist/expect/RelationMatcherBase.d.ts +12 -0
- package/dist/expect/RelationMatcherBase.js +16 -0
- package/dist/expect/ToAcceptProps.d.ts +10 -0
- package/dist/expect/ToAcceptProps.js +52 -0
- package/dist/expect/ToBe.d.ts +13 -0
- package/dist/expect/ToBe.js +18 -0
- package/dist/expect/ToBeApplicable.d.ts +10 -0
- package/dist/expect/ToBeApplicable.js +72 -0
- package/dist/expect/ToBeAssignableFrom.d.ts +9 -0
- package/dist/expect/ToBeAssignableFrom.js +12 -0
- package/dist/expect/ToBeAssignableTo.d.ts +9 -0
- package/dist/expect/ToBeAssignableTo.js +12 -0
- package/dist/expect/ToBeCallableWith.d.ts +11 -0
- package/dist/expect/ToBeCallableWith.js +29 -0
- package/dist/expect/ToBeConstructableWith.d.ts +11 -0
- package/dist/expect/ToBeConstructableWith.js +29 -0
- package/dist/expect/ToBeInstantiableWith.d.ts +10 -0
- package/dist/expect/ToBeInstantiableWith.js +31 -0
- package/dist/expect/ToHaveProperty.d.ts +10 -0
- package/dist/expect/ToHaveProperty.js +59 -0
- package/dist/expect/ToRaiseError.d.ts +9 -0
- package/dist/expect/ToRaiseError.js +82 -0
- package/dist/expect/index.d.ts +2 -0
- package/dist/expect/index.js +1 -0
- package/dist/expect/types.d.ts +7 -0
- package/dist/expect/types.js +1 -0
- package/dist/file/FilePosition.d.ts +7 -0
- package/dist/file/FilePosition.js +16 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +1 -0
- package/dist/glob/Braces.d.ts +4 -0
- package/dist/glob/Braces.js +56 -0
- package/dist/glob/Glob.d.ts +4 -0
- package/dist/glob/Glob.js +47 -0
- package/dist/glob/index.d.ts +1 -0
- package/dist/glob/index.js +1 -0
- package/dist/handlers/CancellationHandler.d.ts +7 -0
- package/dist/handlers/CancellationHandler.js +15 -0
- package/dist/handlers/ExitCodeHandler.d.ts +7 -0
- package/dist/handlers/ExitCodeHandler.js +20 -0
- package/dist/handlers/ResultHandler.d.ts +5 -0
- package/dist/handlers/ResultHandler.js +206 -0
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.js +3 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +40 -45
- package/dist/index.d.ts +40 -45
- package/dist/index.js +1 -2
- package/dist/input/InputService.d.ts +6 -0
- package/dist/input/InputService.js +16 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/json/JsonNode.d.ts +11 -0
- package/dist/json/JsonNode.js +28 -0
- package/dist/json/JsonScanner.d.ts +14 -0
- package/dist/json/JsonScanner.js +105 -0
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.js +2 -0
- package/dist/json/types.d.ts +1 -0
- package/dist/json/types.js +1 -0
- package/dist/layers/AbilityLayer.d.ts +10 -0
- package/dist/layers/AbilityLayer.js +186 -0
- package/dist/layers/Layers.d.ts +11 -0
- package/dist/layers/Layers.js +47 -0
- package/dist/layers/SuppressedLayer.d.ts +11 -0
- package/dist/layers/SuppressedLayer.js +93 -0
- package/dist/layers/index.d.ts +2 -0
- package/dist/layers/index.js +1 -0
- package/dist/layers/types.d.ts +8 -0
- package/dist/layers/types.js +1 -0
- package/dist/output/CodeFrameText.d.ts +10 -0
- package/dist/output/CodeFrameText.js +71 -0
- package/dist/output/OutputService.d.ts +13 -0
- package/dist/output/OutputService.js +38 -0
- package/dist/output/StreamController.d.ts +10 -0
- package/dist/output/StreamController.js +16 -0
- package/dist/output/addsText.d.ts +4 -0
- package/dist/output/addsText.js +8 -0
- package/dist/output/describeNameText.d.ts +2 -0
- package/dist/output/describeNameText.js +5 -0
- package/dist/output/diagnosticText.d.ts +4 -0
- package/dist/output/diagnosticText.js +23 -0
- package/dist/output/dotText.d.ts +3 -0
- package/dist/output/dotText.js +11 -0
- package/dist/output/fileStatusText.d.ts +4 -0
- package/dist/output/fileStatusText.js +26 -0
- package/dist/output/formattedText.d.ts +2 -0
- package/dist/output/formattedText.js +19 -0
- package/dist/output/helpText.d.ts +3 -0
- package/dist/output/helpText.js +52 -0
- package/dist/output/helpers.d.ts +5 -0
- package/dist/output/helpers.js +23 -0
- package/dist/output/index.d.ts +16 -0
- package/dist/output/index.js +15 -0
- package/dist/output/prologueText.d.ts +2 -0
- package/dist/output/prologueText.js +5 -0
- package/dist/output/summaryText.d.ts +12 -0
- package/dist/output/summaryText.js +31 -0
- package/dist/output/testNameText.d.ts +3 -0
- package/dist/output/testNameText.js +24 -0
- package/dist/output/types.d.ts +5 -0
- package/dist/output/types.js +1 -0
- package/dist/output/usesText.d.ts +5 -0
- package/dist/output/usesText.js +22 -0
- package/dist/output/waitingForFileChangesText.d.ts +2 -0
- package/dist/output/waitingForFileChangesText.js +5 -0
- package/dist/output/watchUsageText.d.ts +2 -0
- package/dist/output/watchUsageText.js +12 -0
- package/dist/path/Path.d.ts +7 -0
- package/dist/path/Path.js +28 -0
- package/dist/path/index.d.ts +1 -0
- package/dist/path/index.js +1 -0
- package/dist/project/CompatMappedDiagnostic.d.ts +12 -0
- package/dist/project/CompatMappedDiagnostic.js +25 -0
- package/dist/project/CompatProjectService.d.ts +19 -0
- package/dist/project/CompatProjectService.js +188 -0
- package/dist/project/FileMapService.d.ts +6 -0
- package/dist/project/FileMapService.js +14 -0
- package/dist/project/NativeMappedDiagnostic.d.ts +14 -0
- package/dist/project/NativeMappedDiagnostic.js +29 -0
- package/dist/project/NativeProjectService.d.ts +21 -0
- package/dist/project/NativeProjectService.js +216 -0
- package/dist/project/ProjectConfigService.d.ts +8 -0
- package/dist/project/ProjectConfigService.js +73 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/index.js +2 -0
- package/dist/project/types.d.ts +7 -0
- package/dist/project/types.js +1 -0
- package/dist/reject/Reject.d.ts +9 -0
- package/dist/reject/Reject.js +43 -0
- package/dist/reject/RejectDiagnosticText.d.ts +5 -0
- package/dist/reject/RejectDiagnosticText.js +16 -0
- package/dist/reject/helpers.d.ts +1 -0
- package/dist/reject/helpers.js +3 -0
- package/dist/reject/index.d.ts +1 -0
- package/dist/reject/index.js +1 -0
- package/dist/reporters/BaseReporter.d.ts +7 -0
- package/dist/reporters/BaseReporter.js +6 -0
- package/dist/reporters/DotReporter.d.ts +6 -0
- package/dist/reporters/DotReporter.js +51 -0
- package/dist/reporters/FileView.d.ts +13 -0
- package/dist/reporters/FileView.js +33 -0
- package/dist/reporters/ListReporter.d.ts +6 -0
- package/dist/reporters/ListReporter.js +125 -0
- package/dist/reporters/SetupReporter.d.ts +4 -0
- package/dist/reporters/SetupReporter.js +21 -0
- package/dist/reporters/SummaryReporter.d.ts +5 -0
- package/dist/reporters/SummaryReporter.js +19 -0
- package/dist/reporters/WatchReporter.d.ts +5 -0
- package/dist/reporters/WatchReporter.js +21 -0
- package/dist/reporters/index.d.ts +7 -0
- package/dist/reporters/index.js +6 -0
- package/dist/reporters/types.d.ts +5 -0
- package/dist/reporters/types.js +1 -0
- package/dist/result/DescribeResult.d.ts +9 -0
- package/dist/result/DescribeResult.js +11 -0
- package/dist/result/ExpectResult.d.ts +10 -0
- package/dist/result/ExpectResult.js +11 -0
- package/dist/result/FileResult.d.ts +15 -0
- package/dist/result/FileResult.js +13 -0
- package/dist/result/ProjectConfigKind.enum.d.ts +6 -0
- package/dist/result/ProjectConfigKind.enum.js +7 -0
- package/dist/result/ProjectResult.d.ts +8 -0
- package/dist/result/ProjectResult.js +9 -0
- package/dist/result/Result.d.ts +13 -0
- package/dist/result/Result.js +14 -0
- package/dist/result/ResultStatus.enum.d.ts +10 -0
- package/dist/result/ResultStatus.enum.js +11 -0
- package/dist/result/SuppressedResult.d.ts +5 -0
- package/dist/result/SuppressedResult.js +6 -0
- package/dist/result/TargetResult.d.ts +11 -0
- package/dist/result/TargetResult.js +12 -0
- package/dist/result/TestResult.d.ts +13 -0
- package/dist/result/TestResult.js +13 -0
- package/dist/result/helpers.d.ts +7 -0
- package/dist/result/helpers.js +21 -0
- package/dist/result/index.d.ts +11 -0
- package/dist/result/index.js +10 -0
- package/dist/result/types.d.ts +31 -0
- package/dist/result/types.js +1 -0
- package/dist/runner/FileRunner.d.ts +10 -0
- package/dist/runner/FileRunner.js +93 -0
- package/dist/runner/FixmeDiagnosticText.d.ts +4 -0
- package/dist/runner/FixmeDiagnosticText.js +8 -0
- package/dist/runner/FixmeService.d.ts +9 -0
- package/dist/runner/FixmeService.js +51 -0
- package/dist/runner/RunModeFlags.enum.d.ts +7 -0
- package/dist/runner/RunModeFlags.enum.js +8 -0
- package/dist/runner/Runner.d.ts +9 -0
- package/dist/runner/Runner.js +101 -0
- package/dist/runner/TestTreeWalker.d.ts +19 -0
- package/dist/runner/TestTreeWalker.js +169 -0
- package/dist/runner/index.d.ts +1 -0
- package/dist/runner/index.js +1 -0
- package/dist/scribbler/Color.enum.d.ts +10 -0
- package/dist/scribbler/Color.enum.js +11 -0
- package/dist/scribbler/Line.d.ts +9 -0
- package/dist/scribbler/Line.js +5 -0
- package/dist/scribbler/Scribbler.d.ts +10 -0
- package/dist/scribbler/Scribbler.js +53 -0
- package/dist/scribbler/Text.d.ts +9 -0
- package/dist/scribbler/Text.js +8 -0
- package/dist/scribbler/index.d.ts +5 -0
- package/dist/scribbler/index.js +4 -0
- package/dist/scribbler/jsxRuntime.d.ts +4 -0
- package/dist/scribbler/jsxRuntime.js +4 -0
- package/dist/scribbler/types.d.ts +19 -0
- package/dist/scribbler/types.js +1 -0
- package/dist/select/Select.d.ts +7 -0
- package/dist/select/Select.js +91 -0
- package/dist/select/SelectDiagnosticText.d.ts +6 -0
- package/dist/select/SelectDiagnosticText.js +24 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +2 -0
- package/dist/store/Fetcher.d.ts +8 -0
- package/dist/store/Fetcher.js +52 -0
- package/dist/store/Lock.d.ts +5 -0
- package/dist/store/Lock.js +17 -0
- package/dist/store/LockService.d.ts +8 -0
- package/dist/store/LockService.js +36 -0
- package/dist/store/Manifest.d.ts +35 -0
- package/dist/store/Manifest.js +58 -0
- package/dist/store/ManifestService.d.ts +10 -0
- package/dist/store/ManifestService.js +129 -0
- package/dist/store/PackageService.d.ts +8 -0
- package/dist/store/PackageService.js +69 -0
- package/dist/store/Store.d.ts +12 -0
- package/dist/store/Store.js +103 -0
- package/dist/store/StoreDiagnosticText.d.ts +12 -0
- package/dist/store/StoreDiagnosticText.js +36 -0
- package/dist/store/TarReader.d.ts +9 -0
- package/dist/store/TarReader.js +56 -0
- package/dist/store/helpers.d.ts +1 -0
- package/dist/store/helpers.js +3 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/dist/structure/ComparisonResult.enum.d.ts +5 -0
- package/dist/structure/ComparisonResult.enum.js +6 -0
- package/dist/structure/Structure.d.ts +24 -0
- package/dist/structure/Structure.js +481 -0
- package/dist/structure/index.d.ts +1 -0
- package/dist/structure/index.js +1 -0
- package/dist/suppressed/SuppressedDiagnosticText.d.ts +6 -0
- package/dist/suppressed/SuppressedDiagnosticText.js +18 -0
- package/dist/suppressed/SuppressedService.d.ts +5 -0
- package/dist/suppressed/SuppressedService.js +61 -0
- package/dist/suppressed/index.d.ts +1 -0
- package/dist/suppressed/index.js +1 -0
- package/dist/tag.d.ts +1 -3
- package/dist/tag.js +2 -5
- package/dist/text/TextFile.d.ts +11 -0
- package/dist/text/TextFile.js +41 -0
- package/dist/text/TextFileService.d.ts +10 -0
- package/dist/text/TextFileService.js +31 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +2 -0
- package/dist/text/types.d.ts +5 -0
- package/dist/text/types.js +1 -0
- package/dist/token/CancellationReason.enum.d.ts +6 -0
- package/dist/token/CancellationReason.enum.js +7 -0
- package/dist/token/CancellationToken.d.ts +8 -0
- package/dist/token/CancellationToken.js +22 -0
- package/dist/token/index.d.ts +2 -0
- package/dist/token/index.js +2 -0
- package/dist/typescript/BaseAdapter.d.ts +36 -0
- package/dist/typescript/BaseAdapter.js +83 -0
- package/dist/typescript/CompatTypeScript.d.ts +21 -0
- package/dist/typescript/CompatTypeScript.js +37 -0
- package/dist/typescript/NativeTypeScript.d.ts +24 -0
- package/dist/typescript/NativeTypeScript.js +44 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/typescript/index.js +2 -0
- package/dist/typescript/types.d.ts +69 -0
- package/dist/typescript/types.js +1 -0
- package/dist/version/Version.d.ts +6 -0
- package/dist/version/Version.js +30 -0
- package/dist/version/index.d.ts +1 -0
- package/dist/version/index.js +1 -0
- package/dist/watch/Debounce.d.ts +9 -0
- package/dist/watch/Debounce.js +27 -0
- package/dist/watch/FileWatcher.d.ts +5 -0
- package/dist/watch/FileWatcher.js +12 -0
- package/dist/watch/WatchService.d.ts +8 -0
- package/dist/watch/WatchService.js +96 -0
- package/dist/watch/Watcher.d.ts +10 -0
- package/dist/watch/Watcher.js +31 -0
- package/dist/watch/index.d.ts +3 -0
- package/dist/watch/index.js +3 -0
- package/package.json +9 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Diagnostic, DiagnosticOrigin, getDiagnosticMessageText } from "#diagnostic";
|
|
2
|
+
import { ExpectDiagnosticText } from "./ExpectDiagnosticText.js";
|
|
3
|
+
export class ToRaiseError {
|
|
4
|
+
#ts;
|
|
5
|
+
constructor(ts) {
|
|
6
|
+
this.#ts = ts;
|
|
7
|
+
}
|
|
8
|
+
#explain(expectNode, sourceNode, targetNodes) {
|
|
9
|
+
const isExpression = this.#ts.belongsToArgumentList(sourceNode);
|
|
10
|
+
const origin = DiagnosticOrigin.fromAssertion(expectNode);
|
|
11
|
+
if (expectNode.diagnostics.size === 0) {
|
|
12
|
+
const text = ExpectDiagnosticText.didNotRaiseError(isExpression);
|
|
13
|
+
return [Diagnostic.error(text, origin)];
|
|
14
|
+
}
|
|
15
|
+
if (expectNode.diagnostics.size !== targetNodes.length) {
|
|
16
|
+
const count = expectNode.diagnostics.size;
|
|
17
|
+
const text = ExpectDiagnosticText.raisedError(isExpression, count, targetNodes.length);
|
|
18
|
+
const related = [
|
|
19
|
+
Diagnostic.error(ExpectDiagnosticText.raisedTypeError(count)),
|
|
20
|
+
...Diagnostic.fromDiagnostics([...expectNode.diagnostics]),
|
|
21
|
+
];
|
|
22
|
+
return [Diagnostic.error(text, origin).add({ related })];
|
|
23
|
+
}
|
|
24
|
+
return [...expectNode.diagnostics].reduce((accumulator, diagnostic, index) => {
|
|
25
|
+
const targetNode = targetNodes[index];
|
|
26
|
+
const isMatch = this.#matchExpectedError(diagnostic, targetNode);
|
|
27
|
+
if (expectNode.isNot ? isMatch : !isMatch) {
|
|
28
|
+
const text = expectNode.isNot
|
|
29
|
+
? ExpectDiagnosticText.raisedMatchingError(isExpression)
|
|
30
|
+
: ExpectDiagnosticText.didNotRaiseMatchingError(isExpression);
|
|
31
|
+
const origin = DiagnosticOrigin.fromNode(targetNode, expectNode);
|
|
32
|
+
const related = [
|
|
33
|
+
Diagnostic.error(ExpectDiagnosticText.raisedTypeError()),
|
|
34
|
+
...Diagnostic.fromDiagnostics([diagnostic]),
|
|
35
|
+
];
|
|
36
|
+
accumulator.push(Diagnostic.error(text, origin).add({ related }));
|
|
37
|
+
}
|
|
38
|
+
return accumulator;
|
|
39
|
+
}, []);
|
|
40
|
+
}
|
|
41
|
+
match(expectNode, sourceNode, targetNodes, onDiagnostics) {
|
|
42
|
+
const diagnostics = [];
|
|
43
|
+
for (const targetNode of targetNodes) {
|
|
44
|
+
if (!(this.#ts.isStringLiteralLikeNode(targetNode) ||
|
|
45
|
+
this.#ts.isNumericLiteral(targetNode) ||
|
|
46
|
+
this.#ts.isRegularExpressionLiteral(targetNode))) {
|
|
47
|
+
const expectedText = "a string, number or regular expression";
|
|
48
|
+
const text = ExpectDiagnosticText.argumentMustBe(expectedText);
|
|
49
|
+
const origin = DiagnosticOrigin.fromNode(targetNode);
|
|
50
|
+
diagnostics.push(Diagnostic.error(text, origin));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (diagnostics.length > 0) {
|
|
54
|
+
onDiagnostics(diagnostics);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let isMatch;
|
|
58
|
+
if (targetNodes.length === 0) {
|
|
59
|
+
isMatch = expectNode.diagnostics.size > 0;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
isMatch =
|
|
63
|
+
expectNode.diagnostics.size === targetNodes.length &&
|
|
64
|
+
[...expectNode.diagnostics].every((diagnostic, index) => this.#matchExpectedError(diagnostic, targetNodes[index]));
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
explain: () => this.#explain(expectNode, sourceNode, targetNodes),
|
|
68
|
+
isMatch,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
#matchExpectedError(diagnostic, targetNode) {
|
|
72
|
+
if (this.#ts.isNumericLiteral(targetNode)) {
|
|
73
|
+
return Number.parseInt(targetNode.text, 10) === diagnostic.code;
|
|
74
|
+
}
|
|
75
|
+
const messageText = getDiagnosticMessageText(diagnostic).join("\n");
|
|
76
|
+
if (this.#ts.isRegularExpressionLiteral(targetNode)) {
|
|
77
|
+
const targetRegex = new RegExp(...targetNode.text.slice(1).split("/"));
|
|
78
|
+
return targetRegex.test(messageText);
|
|
79
|
+
}
|
|
80
|
+
return messageText.includes(targetNode.text);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExpectService } from "./ExpectService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { Path } from "#path";
|
|
3
|
+
export class FilePosition {
|
|
4
|
+
path;
|
|
5
|
+
position;
|
|
6
|
+
constructor(file, position) {
|
|
7
|
+
this.path = Path.resolve(this.#toPath(file));
|
|
8
|
+
this.position = position;
|
|
9
|
+
}
|
|
10
|
+
#toPath(file) {
|
|
11
|
+
if (typeof file === "string" && !file.startsWith("file:")) {
|
|
12
|
+
return file;
|
|
13
|
+
}
|
|
14
|
+
return fileURLToPath(file);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilePosition } from "./FilePosition.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilePosition } from "./FilePosition.js";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class Braces {
|
|
2
|
+
static expand(text) {
|
|
3
|
+
const start = text.indexOf("{");
|
|
4
|
+
if (start === -1) {
|
|
5
|
+
return [text];
|
|
6
|
+
}
|
|
7
|
+
let position = start;
|
|
8
|
+
let depth = 0;
|
|
9
|
+
for (position; position < text.length; position++) {
|
|
10
|
+
if (text[position] === "{") {
|
|
11
|
+
depth++;
|
|
12
|
+
}
|
|
13
|
+
else if (text[position] === "}") {
|
|
14
|
+
depth--;
|
|
15
|
+
}
|
|
16
|
+
if (depth === 0) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (depth !== 0) {
|
|
21
|
+
return [text];
|
|
22
|
+
}
|
|
23
|
+
const before = text.slice(0, start);
|
|
24
|
+
const options = Braces.#splitOptions(text.slice(start + 1, position));
|
|
25
|
+
const after = text.slice(position + 1);
|
|
26
|
+
const result = [];
|
|
27
|
+
for (const option of options) {
|
|
28
|
+
for (const expanded of Braces.expand(option + after)) {
|
|
29
|
+
result.push(before + expanded);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
static #splitOptions(optionText) {
|
|
35
|
+
const options = [];
|
|
36
|
+
let current = "";
|
|
37
|
+
let depth = 0;
|
|
38
|
+
for (const character of optionText) {
|
|
39
|
+
if (character === "," && depth === 0) {
|
|
40
|
+
options.push(current);
|
|
41
|
+
current = "";
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (character === "{") {
|
|
45
|
+
depth++;
|
|
46
|
+
}
|
|
47
|
+
if (character === "}") {
|
|
48
|
+
depth--;
|
|
49
|
+
}
|
|
50
|
+
current += character;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
options.push(current);
|
|
54
|
+
return options;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Braces } from "./Braces.js";
|
|
2
|
+
export class Glob {
|
|
3
|
+
static #reservedCharacterRegex = /[^\w\s/]/g;
|
|
4
|
+
static #parse(pattern, usageTarget) {
|
|
5
|
+
const segments = pattern.split("/");
|
|
6
|
+
let resultPattern = "\\.";
|
|
7
|
+
let optionalSegmentCount = 0;
|
|
8
|
+
for (const segment of segments) {
|
|
9
|
+
if (segment === ".") {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (segment === "**") {
|
|
13
|
+
resultPattern += "(\\/(?!(node_modules)(\\/|$))[^./][^/]*)*?";
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (usageTarget === "directories") {
|
|
17
|
+
resultPattern += "(";
|
|
18
|
+
optionalSegmentCount++;
|
|
19
|
+
}
|
|
20
|
+
resultPattern += "\\/";
|
|
21
|
+
const segmentPattern = segment.replace(Glob.#reservedCharacterRegex, Glob.#replaceReservedCharacter);
|
|
22
|
+
if (segmentPattern !== segment) {
|
|
23
|
+
resultPattern += "(?!(node_modules)(\\/|$))";
|
|
24
|
+
}
|
|
25
|
+
resultPattern += segmentPattern;
|
|
26
|
+
}
|
|
27
|
+
resultPattern += ")?".repeat(optionalSegmentCount);
|
|
28
|
+
return resultPattern;
|
|
29
|
+
}
|
|
30
|
+
static #replaceReservedCharacter(match, offset) {
|
|
31
|
+
switch (match) {
|
|
32
|
+
case "*":
|
|
33
|
+
return offset === 0 ? "([^./][^/]*)?" : "([^/]*)?";
|
|
34
|
+
case "?":
|
|
35
|
+
return offset === 0 ? "[^./]" : "[^/]";
|
|
36
|
+
default:
|
|
37
|
+
return `\\${match}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static toRegex(patterns, target) {
|
|
41
|
+
const patternText = patterns
|
|
42
|
+
.flatMap((pattern) => Braces.expand(pattern))
|
|
43
|
+
.map((pattern) => `(${Glob.#parse(pattern, target)})`)
|
|
44
|
+
.join("|");
|
|
45
|
+
return new RegExp(`^(${patternText})$`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Glob } from "./Glob.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Glob } from "./Glob.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Event, EventHandler } from "#events";
|
|
2
|
+
import type { CancellationReason, CancellationToken } from "#token";
|
|
3
|
+
export declare class CancellationHandler implements EventHandler {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(cancellationToken: CancellationToken, cancellationReason: CancellationReason);
|
|
6
|
+
on([, payload]: Event): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class CancellationHandler {
|
|
2
|
+
#cancellationToken;
|
|
3
|
+
#cancellationReason;
|
|
4
|
+
constructor(cancellationToken, cancellationReason) {
|
|
5
|
+
this.#cancellationToken = cancellationToken;
|
|
6
|
+
this.#cancellationReason = cancellationReason;
|
|
7
|
+
}
|
|
8
|
+
on([, payload]) {
|
|
9
|
+
if ("diagnostics" in payload) {
|
|
10
|
+
if (payload.diagnostics.some((diagnostic) => diagnostic.category === "error")) {
|
|
11
|
+
this.#cancellationToken.cancel(this.#cancellationReason);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class ExitCodeHandler {
|
|
2
|
+
#exitCode = 0;
|
|
3
|
+
getExitCode() {
|
|
4
|
+
return this.#exitCode;
|
|
5
|
+
}
|
|
6
|
+
on([event, payload]) {
|
|
7
|
+
if (event === "run:start") {
|
|
8
|
+
this.#exitCode = 0;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if ("diagnostics" in payload) {
|
|
12
|
+
if (payload.diagnostics.some((diagnostic) => diagnostic.category === "error")) {
|
|
13
|
+
this.#exitCode = 1;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
reset() {
|
|
18
|
+
this.#exitCode = 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { ProjectResult, } from "#result";
|
|
2
|
+
export class ResultHandler {
|
|
3
|
+
#describeResult;
|
|
4
|
+
#expectResult;
|
|
5
|
+
#fileResult;
|
|
6
|
+
#projectResult;
|
|
7
|
+
#result;
|
|
8
|
+
#targetResult;
|
|
9
|
+
#testResult;
|
|
10
|
+
on([event, payload]) {
|
|
11
|
+
switch (event) {
|
|
12
|
+
case "run:start":
|
|
13
|
+
this.#result = payload.result;
|
|
14
|
+
this.#result.timing.start = Date.now();
|
|
15
|
+
break;
|
|
16
|
+
case "run:end":
|
|
17
|
+
this.#result.timing.end = Date.now();
|
|
18
|
+
this.#result = undefined;
|
|
19
|
+
break;
|
|
20
|
+
case "target:start":
|
|
21
|
+
this.#result.results.push(payload.result);
|
|
22
|
+
this.#targetResult = payload.result;
|
|
23
|
+
this.#targetResult.timing.start = Date.now();
|
|
24
|
+
break;
|
|
25
|
+
case "target:end":
|
|
26
|
+
if (this.#targetResult.status === "failed") {
|
|
27
|
+
this.#result.targetCounts.failed++;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.#result.targetCounts.passed++;
|
|
31
|
+
this.#targetResult.status = "passed";
|
|
32
|
+
}
|
|
33
|
+
this.#targetResult.timing.end = Date.now();
|
|
34
|
+
this.#targetResult = undefined;
|
|
35
|
+
break;
|
|
36
|
+
case "store:error":
|
|
37
|
+
if (payload.diagnostics.some(({ category }) => category === "error")) {
|
|
38
|
+
this.#targetResult.status = "failed";
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case "project:uses": {
|
|
42
|
+
let projectResult = this.#targetResult.results.get(payload.projectConfig.specifier);
|
|
43
|
+
if (!projectResult) {
|
|
44
|
+
projectResult = new ProjectResult(payload.compilerVersion, payload.projectConfig);
|
|
45
|
+
this.#targetResult.results.set(payload.projectConfig.specifier, projectResult);
|
|
46
|
+
}
|
|
47
|
+
this.#projectResult = projectResult;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "project:error":
|
|
51
|
+
this.#targetResult.status = "failed";
|
|
52
|
+
break;
|
|
53
|
+
case "file:start":
|
|
54
|
+
this.#projectResult.results.push(payload.result);
|
|
55
|
+
this.#fileResult = payload.result;
|
|
56
|
+
this.#fileResult.timing.start = Date.now();
|
|
57
|
+
break;
|
|
58
|
+
case "file:error":
|
|
59
|
+
case "directive:error":
|
|
60
|
+
case "collect:error":
|
|
61
|
+
this.#targetResult.status = "failed";
|
|
62
|
+
this.#fileResult.status = "failed";
|
|
63
|
+
break;
|
|
64
|
+
case "file:end":
|
|
65
|
+
if (this.#fileResult.status === "failed" ||
|
|
66
|
+
this.#fileResult.assertionCounts.failed > 0 ||
|
|
67
|
+
this.#fileResult.testCounts.failed > 0) {
|
|
68
|
+
this.#result.fileCounts.failed++;
|
|
69
|
+
this.#targetResult.status = "failed";
|
|
70
|
+
this.#fileResult.status = "failed";
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.#result.fileCounts.passed++;
|
|
74
|
+
this.#fileResult.status = "passed";
|
|
75
|
+
}
|
|
76
|
+
this.#fileResult.timing.end = Date.now();
|
|
77
|
+
this.#fileResult = undefined;
|
|
78
|
+
break;
|
|
79
|
+
case "describe:start":
|
|
80
|
+
if (this.#describeResult) {
|
|
81
|
+
this.#describeResult.results.push(payload.result);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.#fileResult.results.push(payload.result);
|
|
85
|
+
}
|
|
86
|
+
this.#describeResult = payload.result;
|
|
87
|
+
this.#describeResult.timing.start = Date.now();
|
|
88
|
+
break;
|
|
89
|
+
case "describe:end":
|
|
90
|
+
this.#describeResult.timing.end = Date.now();
|
|
91
|
+
this.#describeResult = this.#describeResult.parent;
|
|
92
|
+
break;
|
|
93
|
+
case "test:start":
|
|
94
|
+
if (this.#describeResult) {
|
|
95
|
+
this.#describeResult.results.push(payload.result);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.#fileResult.results.push(payload.result);
|
|
99
|
+
}
|
|
100
|
+
this.#testResult = payload.result;
|
|
101
|
+
this.#testResult.timing.start = Date.now();
|
|
102
|
+
break;
|
|
103
|
+
case "test:error":
|
|
104
|
+
case "test:fail":
|
|
105
|
+
this.#result.testCounts.failed++;
|
|
106
|
+
this.#fileResult.testCounts.failed++;
|
|
107
|
+
this.#testResult.status = "failed";
|
|
108
|
+
this.#testResult.timing.end = Date.now();
|
|
109
|
+
this.#testResult = undefined;
|
|
110
|
+
break;
|
|
111
|
+
case "test:pass":
|
|
112
|
+
this.#result.testCounts.passed++;
|
|
113
|
+
this.#fileResult.testCounts.passed++;
|
|
114
|
+
this.#testResult.status = "passed";
|
|
115
|
+
this.#testResult.timing.end = Date.now();
|
|
116
|
+
this.#testResult = undefined;
|
|
117
|
+
break;
|
|
118
|
+
case "test:skip":
|
|
119
|
+
this.#result.testCounts.skipped++;
|
|
120
|
+
this.#fileResult.testCounts.skipped++;
|
|
121
|
+
this.#testResult.status = "skipped";
|
|
122
|
+
this.#testResult.timing.end = Date.now();
|
|
123
|
+
this.#testResult = undefined;
|
|
124
|
+
break;
|
|
125
|
+
case "test:fixme":
|
|
126
|
+
this.#result.testCounts.fixme++;
|
|
127
|
+
this.#fileResult.testCounts.fixme++;
|
|
128
|
+
this.#testResult.status = "fixme";
|
|
129
|
+
this.#testResult.timing.end = Date.now();
|
|
130
|
+
this.#testResult = undefined;
|
|
131
|
+
break;
|
|
132
|
+
case "test:todo":
|
|
133
|
+
this.#result.testCounts.todo++;
|
|
134
|
+
this.#fileResult.testCounts.todo++;
|
|
135
|
+
this.#testResult.status = "todo";
|
|
136
|
+
this.#testResult.timing.end = Date.now();
|
|
137
|
+
this.#testResult = undefined;
|
|
138
|
+
break;
|
|
139
|
+
case "expect:start":
|
|
140
|
+
if (this.#testResult) {
|
|
141
|
+
this.#testResult.results.push(payload.result);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
this.#fileResult.results.push(payload.result);
|
|
145
|
+
}
|
|
146
|
+
this.#expectResult = payload.result;
|
|
147
|
+
this.#expectResult.timing.start = Date.now();
|
|
148
|
+
break;
|
|
149
|
+
case "expect:error":
|
|
150
|
+
case "expect:fail":
|
|
151
|
+
this.#result.assertionCounts.failed++;
|
|
152
|
+
this.#fileResult.assertionCounts.failed++;
|
|
153
|
+
if (this.#testResult) {
|
|
154
|
+
this.#testResult.assertionCounts.failed++;
|
|
155
|
+
}
|
|
156
|
+
this.#expectResult.status = "failed";
|
|
157
|
+
this.#expectResult.timing.end = Date.now();
|
|
158
|
+
this.#expectResult = undefined;
|
|
159
|
+
break;
|
|
160
|
+
case "expect:pass":
|
|
161
|
+
this.#result.assertionCounts.passed++;
|
|
162
|
+
this.#fileResult.assertionCounts.passed++;
|
|
163
|
+
if (this.#testResult) {
|
|
164
|
+
this.#testResult.assertionCounts.passed++;
|
|
165
|
+
}
|
|
166
|
+
this.#expectResult.status = "passed";
|
|
167
|
+
this.#expectResult.timing.end = Date.now();
|
|
168
|
+
this.#expectResult = undefined;
|
|
169
|
+
break;
|
|
170
|
+
case "expect:skip":
|
|
171
|
+
this.#result.assertionCounts.skipped++;
|
|
172
|
+
this.#fileResult.assertionCounts.skipped++;
|
|
173
|
+
if (this.#testResult) {
|
|
174
|
+
this.#testResult.assertionCounts.skipped++;
|
|
175
|
+
}
|
|
176
|
+
this.#expectResult.status = "skipped";
|
|
177
|
+
this.#expectResult.timing.end = Date.now();
|
|
178
|
+
this.#expectResult = undefined;
|
|
179
|
+
break;
|
|
180
|
+
case "expect:fixme":
|
|
181
|
+
this.#result.assertionCounts.fixme++;
|
|
182
|
+
this.#fileResult.assertionCounts.fixme++;
|
|
183
|
+
if (this.#testResult) {
|
|
184
|
+
this.#testResult.assertionCounts.fixme++;
|
|
185
|
+
}
|
|
186
|
+
this.#expectResult.status = "fixme";
|
|
187
|
+
this.#expectResult.timing.end = Date.now();
|
|
188
|
+
this.#expectResult = undefined;
|
|
189
|
+
break;
|
|
190
|
+
case "suppressed:error":
|
|
191
|
+
this.#result.suppressedCounts.failed++;
|
|
192
|
+
this.#fileResult.suppressedCounts.failed++;
|
|
193
|
+
this.#targetResult.status = "failed";
|
|
194
|
+
this.#fileResult.status = "failed";
|
|
195
|
+
break;
|
|
196
|
+
case "suppressed:match":
|
|
197
|
+
this.#result.suppressedCounts.matched++;
|
|
198
|
+
this.#fileResult.suppressedCounts.matched++;
|
|
199
|
+
break;
|
|
200
|
+
case "suppressed:ignore":
|
|
201
|
+
this.#result.suppressedCounts.ignored++;
|
|
202
|
+
this.#fileResult.suppressedCounts.ignored++;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test = exports.it = exports.expect = exports.describe = void 0;
|
|
4
|
+
exports.omit = noop;
|
|
5
|
+
exports.pick = noop;
|
|
3
6
|
function noop() {
|
|
4
7
|
}
|
|
5
8
|
const noopChain = new Proxy(noop, {
|
|
@@ -10,10 +13,7 @@ const noopChain = new Proxy(noop, {
|
|
|
10
13
|
return noopChain;
|
|
11
14
|
},
|
|
12
15
|
});
|
|
13
|
-
|
|
14
16
|
exports.describe = noopChain;
|
|
15
17
|
exports.expect = noopChain;
|
|
16
18
|
exports.it = noopChain;
|
|
17
|
-
exports.omit = noop;
|
|
18
|
-
exports.pick = noop;
|
|
19
19
|
exports.test = noopChain;
|