@fgv/ts-utils-jest 5.0.0-2 → 5.0.0-21
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/.vscode/launch.json +16 -0
- package/README.md +11 -0
- package/config/api-extractor.json +343 -0
- package/config/jest-disable-colors.js +34 -0
- package/config/rig.json +16 -0
- package/lib/helpers/fsHelpers.test.d.ts +2 -0
- package/lib/index.test.d.ts +2 -0
- package/lib/matchers/toFail/index.test.d.ts +2 -0
- package/lib/matchers/toFail/predicate.test.d.ts +2 -0
- package/lib/matchers/toFailTest/index.test.d.ts +2 -0
- package/lib/matchers/toFailTest/predicate.test.d.ts +2 -0
- package/lib/matchers/toFailTestAndMatchSnapshot/index.js +2 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/index.test.d.ts +2 -0
- package/lib/matchers/toFailTestAndMatchSnapshot/predicate.test.d.ts +2 -0
- package/lib/matchers/toFailTestWith/index.test.d.ts +2 -0
- package/lib/matchers/toFailTestWith/predicate.test.d.ts +2 -0
- package/lib/matchers/toFailWith/index.test.d.ts +2 -0
- package/lib/matchers/toFailWith/predicate.test.d.ts +2 -0
- package/lib/matchers/toFailWithDetail/index.test.d.ts +2 -0
- package/lib/matchers/toFailWithDetail/predicate.test.d.ts +2 -0
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/index.test.d.ts +2 -0
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.test.d.ts +2 -0
- package/lib/matchers/toSucceed/index.test.d.ts +2 -0
- package/lib/matchers/toSucceed/predicate.test.d.ts +2 -0
- package/lib/matchers/toSucceedAndMatchInlineSnapshot/index.test.d.ts +2 -0
- package/lib/matchers/toSucceedAndMatchSnapshot/index.test.d.ts +2 -0
- package/lib/matchers/toSucceedAndSatisfy/index.test.d.ts +2 -0
- package/lib/matchers/toSucceedAndSatisfy/predicate.test.d.ts +2 -0
- package/lib/matchers/toSucceedWith/index.test.d.ts +2 -0
- package/lib/matchers/toSucceedWith/predicate.test.d.ts +2 -0
- package/lib/matchers/toSucceedWithDetail/index.test.d.ts +2 -0
- package/lib/matchers/toSucceedWithDetail/predicate.test.d.ts +2 -0
- package/lib/resolvers/resolvers.test.d.ts +2 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils/colorHelpers.d.ts +54 -0
- package/lib/utils/colorHelpers.js +84 -0
- package/lib/utils/matcherHelpers.js +9 -5
- package/package.json +8 -8
- package/src/__snapshots__/index.test.ts.snap +24 -0
- package/src/helpers/fsHelpers.ts +184 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +27 -0
- package/src/matchers/index.ts +29 -0
- package/src/matchers/toFail/__snapshots__/index.test.ts.snap +17 -0
- package/src/matchers/toFail/index.ts +45 -0
- package/src/matchers/toFail/predicate.ts +7 -0
- package/src/matchers/toFailTest/__snapshots__/index.test.ts.snap +15 -0
- package/src/matchers/toFailTest/index.ts +48 -0
- package/src/matchers/toFailTest/predicate.ts +8 -0
- package/src/matchers/toFailTestAndMatchSnapshot/__snapshots__/index.test.ts.snap +14 -0
- package/src/matchers/toFailTestAndMatchSnapshot/index.ts +48 -0
- package/src/matchers/toFailTestAndMatchSnapshot/predicate.ts +12 -0
- package/src/matchers/toFailTestWith/__snapshots__/index.test.ts.snap +34 -0
- package/src/matchers/toFailTestWith/index.ts +56 -0
- package/src/matchers/toFailTestWith/predicate.ts +24 -0
- package/src/matchers/toFailWith/__snapshots__/index.test.ts.snap +25 -0
- package/src/matchers/toFailWith/index.ts +52 -0
- package/src/matchers/toFailWith/predicate.ts +16 -0
- package/src/matchers/toFailWithDetail/__snapshots__/index.test.ts.snap +41 -0
- package/src/matchers/toFailWithDetail/index.ts +63 -0
- package/src/matchers/toFailWithDetail/predicate.ts +27 -0
- package/src/matchers/toHaveBeenCalledWithArgumentsMatching/__snapshots__/index.test.ts.snap +82 -0
- package/src/matchers/toHaveBeenCalledWithArgumentsMatching/index.ts +100 -0
- package/src/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.ts +18 -0
- package/src/matchers/toSucceed/__snapshots__/index.test.ts.snap +17 -0
- package/src/matchers/toSucceed/index.ts +45 -0
- package/src/matchers/toSucceed/predicate.ts +7 -0
- package/src/matchers/toSucceedAndMatchInlineSnapshot/__snapshots__/index.test.ts.snap +15 -0
- package/src/matchers/toSucceedAndMatchInlineSnapshot/index.ts +44 -0
- package/src/matchers/toSucceedAndMatchSnapshot/__snapshots__/index.test.ts.snap +27 -0
- package/src/matchers/toSucceedAndMatchSnapshot/index.ts +47 -0
- package/src/matchers/toSucceedAndSatisfy/__snapshots__/index.test.ts.snap +37 -0
- package/src/matchers/toSucceedAndSatisfy/index.ts +78 -0
- package/src/matchers/toSucceedAndSatisfy/predicate.ts +22 -0
- package/src/matchers/toSucceedWith/__snapshots__/index.test.ts.snap +25 -0
- package/src/matchers/toSucceedWith/index.ts +58 -0
- package/src/matchers/toSucceedWith/predicate.ts +14 -0
- package/src/matchers/toSucceedWithDetail/__snapshots__/index.test.ts.snap +41 -0
- package/src/matchers/toSucceedWithDetail/index.ts +62 -0
- package/src/matchers/toSucceedWithDetail/predicate.ts +23 -0
- package/src/resolvers/cli.ts +21 -0
- package/src/resolvers/ide.ts +21 -0
- package/src/ts-utils.ts +1 -0
- package/src/types/index.ts +107 -0
- package/src/utils/colorHelpers.ts +82 -0
- package/src/utils/matcherHelpers.ts +64 -0
- package/src/utils/snapshotResolver.ts +28 -0
- package/test/data/testData.json +4 -0
- package/CHANGELOG.md +0 -105
- package/lib/helpers/fsHelpers.d.ts.map +0 -1
- package/lib/helpers/fsHelpers.js.map +0 -1
- package/lib/helpers/index.d.ts.map +0 -1
- package/lib/helpers/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/matchers/index.d.ts.map +0 -1
- package/lib/matchers/index.js.map +0 -1
- package/lib/matchers/toFail/index.d.ts.map +0 -1
- package/lib/matchers/toFail/index.js.map +0 -1
- package/lib/matchers/toFail/predicate.d.ts.map +0 -1
- package/lib/matchers/toFail/predicate.js.map +0 -1
- package/lib/matchers/toFailTest/index.d.ts.map +0 -1
- package/lib/matchers/toFailTest/index.js.map +0 -1
- package/lib/matchers/toFailTest/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailTest/predicate.js.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/index.d.ts.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/index.js.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/predicate.js.map +0 -1
- package/lib/matchers/toFailTestWith/index.d.ts.map +0 -1
- package/lib/matchers/toFailTestWith/index.js.map +0 -1
- package/lib/matchers/toFailTestWith/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailTestWith/predicate.js.map +0 -1
- package/lib/matchers/toFailWith/index.d.ts.map +0 -1
- package/lib/matchers/toFailWith/index.js.map +0 -1
- package/lib/matchers/toFailWith/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailWith/predicate.js.map +0 -1
- package/lib/matchers/toFailWithDetail/index.d.ts.map +0 -1
- package/lib/matchers/toFailWithDetail/index.js.map +0 -1
- package/lib/matchers/toFailWithDetail/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailWithDetail/predicate.js.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/index.d.ts.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/index.js.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.d.ts.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.js.map +0 -1
- package/lib/matchers/toSucceed/index.d.ts.map +0 -1
- package/lib/matchers/toSucceed/index.js.map +0 -1
- package/lib/matchers/toSucceed/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceed/predicate.js.map +0 -1
- package/lib/matchers/toSucceedAndMatchInlineSnapshot/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndMatchInlineSnapshot/index.js.map +0 -1
- package/lib/matchers/toSucceedAndMatchSnapshot/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndMatchSnapshot/index.js.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/index.js.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/predicate.js.map +0 -1
- package/lib/matchers/toSucceedWith/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedWith/index.js.map +0 -1
- package/lib/matchers/toSucceedWith/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceedWith/predicate.js.map +0 -1
- package/lib/matchers/toSucceedWithDetail/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedWithDetail/index.js.map +0 -1
- package/lib/matchers/toSucceedWithDetail/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceedWithDetail/predicate.js.map +0 -1
- package/lib/resolvers/cli.d.ts.map +0 -1
- package/lib/resolvers/cli.js.map +0 -1
- package/lib/resolvers/ide.d.ts.map +0 -1
- package/lib/resolvers/ide.js.map +0 -1
- package/lib/ts-utils.d.ts.map +0 -1
- package/lib/ts-utils.js.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/utils/matcherHelpers.d.ts.map +0 -1
- package/lib/utils/matcherHelpers.js.map +0 -1
- package/lib/utils/snapshotResolver.d.ts.map +0 -1
- package/lib/utils/snapshotResolver.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch Program",
|
|
11
|
+
"skipFiles": ["<node_internals>/**"],
|
|
12
|
+
"program": "${workspaceFolder}/src/matchers/toHaveBeenCalledWithArgumentsMatching/index.test.ts",
|
|
13
|
+
"outFiles": ["${workspaceFolder}/**/*.js"]
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Also includes a handful of custom matchers to simplify the testing of other cust
|
|
|
16
16
|
- [Summary](#summary)
|
|
17
17
|
- [Installation](#installation)
|
|
18
18
|
- [Setup](#setup)
|
|
19
|
+
- [ANSI Color Stripping](#ansi-color-stripping)
|
|
19
20
|
- [API](#api)
|
|
20
21
|
- [Testing Result\<T\>](#testing-resultt)
|
|
21
22
|
- [.toFail()](#tofail)
|
|
@@ -43,6 +44,16 @@ npm install --save-dev @fgv/ts-utils-jest
|
|
|
43
44
|
|
|
44
45
|
Note that snapshot testing for Jest itself can be tricky because different environments (e.g. CLI vs IDE vs CICD) might generate slightly different output due to e.g. differences in color display of diffs. To facilitate snapshot testing across multiple environments, this library also provides an extensible set of snapshot resolvers that can be used to capture environment-specific snapshots.
|
|
45
46
|
|
|
47
|
+
### ANSI Color Stripping
|
|
48
|
+
|
|
49
|
+
**All matchers in this library automatically strip ANSI color codes** from Jest output to ensure consistent snapshots across different terminal environments. This includes:
|
|
50
|
+
|
|
51
|
+
- **Jest matcher utilities** (`printExpected`, `printReceived`) used in error messages
|
|
52
|
+
- **Snapshot content** passed to `toMatchSnapshot()` and `toFailTestAndMatchSnapshot()`
|
|
53
|
+
- **Test failure messages** captured by custom matcher testing utilities
|
|
54
|
+
|
|
55
|
+
This means you can run tests with any terminal color settings (`FORCE_COLOR=0`, `FORCE_COLOR=1`, or default) and get identical snapshot results. No special configuration is required - the color stripping happens automatically.
|
|
56
|
+
|
|
46
57
|
## API
|
|
47
58
|
|
|
48
59
|
### Testing Result\<T\>
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
|
|
3
|
+
*/
|
|
4
|
+
{
|
|
5
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
6
|
+
/**
|
|
7
|
+
* Optionally specifies another JSON config file that this file extends from. This provides a way for
|
|
8
|
+
* standard settings to be shared across multiple projects.
|
|
9
|
+
*
|
|
10
|
+
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
|
|
11
|
+
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
|
|
12
|
+
* resolved using NodeJS require().
|
|
13
|
+
*
|
|
14
|
+
* SUPPORTED TOKENS: none
|
|
15
|
+
* DEFAULT VALUE: ""
|
|
16
|
+
*/
|
|
17
|
+
// "extends": "./shared/api-extractor-base.json"
|
|
18
|
+
// "extends": "my-package/include/api-extractor-base.json"
|
|
19
|
+
/**
|
|
20
|
+
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
|
|
21
|
+
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
|
|
22
|
+
*
|
|
23
|
+
* The path is resolved relative to the folder of the config file that contains the setting.
|
|
24
|
+
*
|
|
25
|
+
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
|
|
26
|
+
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
|
|
27
|
+
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
|
|
28
|
+
* will be reported.
|
|
29
|
+
*
|
|
30
|
+
* SUPPORTED TOKENS: <lookup>
|
|
31
|
+
* DEFAULT VALUE: "<lookup>"
|
|
32
|
+
*/
|
|
33
|
+
"projectFolder": "..",
|
|
34
|
+
/**
|
|
35
|
+
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
|
|
36
|
+
* analyzes the symbols exported by this module.
|
|
37
|
+
*
|
|
38
|
+
* The file extension must be ".d.ts" and not ".ts".
|
|
39
|
+
*
|
|
40
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
41
|
+
* prepend a folder token such as "<projectFolder>".
|
|
42
|
+
*
|
|
43
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
44
|
+
*/
|
|
45
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
|
|
46
|
+
/**
|
|
47
|
+
* A list of NPM package names whose exports should be treated as part of this package.
|
|
48
|
+
*
|
|
49
|
+
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
|
|
50
|
+
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
|
|
51
|
+
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
|
|
52
|
+
* imports library2. To avoid this, we can specify:
|
|
53
|
+
*
|
|
54
|
+
* "bundledPackages": [ "library2" ],
|
|
55
|
+
*
|
|
56
|
+
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
|
|
57
|
+
* local files for library1.
|
|
58
|
+
*/
|
|
59
|
+
"bundledPackages": [],
|
|
60
|
+
/**
|
|
61
|
+
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
|
|
62
|
+
*/
|
|
63
|
+
"compiler": {
|
|
64
|
+
/**
|
|
65
|
+
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
|
|
66
|
+
*
|
|
67
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
68
|
+
* prepend a folder token such as "<projectFolder>".
|
|
69
|
+
*
|
|
70
|
+
* Note: This setting will be ignored if "overrideTsconfig" is used.
|
|
71
|
+
*
|
|
72
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
73
|
+
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
|
|
74
|
+
*/
|
|
75
|
+
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
|
|
76
|
+
/**
|
|
77
|
+
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
|
|
78
|
+
* The object must conform to the TypeScript tsconfig schema:
|
|
79
|
+
*
|
|
80
|
+
* http://json.schemastore.org/tsconfig
|
|
81
|
+
*
|
|
82
|
+
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
|
|
83
|
+
*
|
|
84
|
+
* DEFAULT VALUE: no overrideTsconfig section
|
|
85
|
+
*/
|
|
86
|
+
// "overrideTsconfig": {
|
|
87
|
+
// . . .
|
|
88
|
+
// }
|
|
89
|
+
/**
|
|
90
|
+
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
|
|
91
|
+
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
|
|
92
|
+
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
|
|
93
|
+
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
|
|
94
|
+
*
|
|
95
|
+
* DEFAULT VALUE: false
|
|
96
|
+
*/
|
|
97
|
+
// "skipLibCheck": true,
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Configures how the API report file (*.api.md) will be generated.
|
|
101
|
+
*/
|
|
102
|
+
"apiReport": {
|
|
103
|
+
/**
|
|
104
|
+
* (REQUIRED) Whether to generate an API report.
|
|
105
|
+
*/
|
|
106
|
+
"enabled": true
|
|
107
|
+
/**
|
|
108
|
+
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
|
|
109
|
+
* a full file path.
|
|
110
|
+
*
|
|
111
|
+
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
|
|
112
|
+
*
|
|
113
|
+
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
|
|
114
|
+
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
|
|
115
|
+
*/
|
|
116
|
+
// "reportFileName": "<unscopedPackageName>.api.md",
|
|
117
|
+
/**
|
|
118
|
+
* Specifies the folder where the API report file is written. The file name portion is determined by
|
|
119
|
+
* the "reportFileName" setting.
|
|
120
|
+
*
|
|
121
|
+
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
|
|
122
|
+
* e.g. for an API review.
|
|
123
|
+
*
|
|
124
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
125
|
+
* prepend a folder token such as "<projectFolder>".
|
|
126
|
+
*
|
|
127
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
128
|
+
* DEFAULT VALUE: "<projectFolder>/etc/"
|
|
129
|
+
*/
|
|
130
|
+
// "reportFolder": "<projectFolder>/etc/",
|
|
131
|
+
/**
|
|
132
|
+
* Specifies the folder where the temporary report file is written. The file name portion is determined by
|
|
133
|
+
* the "reportFileName" setting.
|
|
134
|
+
*
|
|
135
|
+
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
|
|
136
|
+
* If they are different, a production build will fail.
|
|
137
|
+
*
|
|
138
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
139
|
+
* prepend a folder token such as "<projectFolder>".
|
|
140
|
+
*
|
|
141
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
142
|
+
* DEFAULT VALUE: "<projectFolder>/temp/"
|
|
143
|
+
*/
|
|
144
|
+
// "reportTempFolder": "<projectFolder>/temp/"
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Configures how the doc model file (*.api.json) will be generated.
|
|
148
|
+
*/
|
|
149
|
+
"docModel": {
|
|
150
|
+
/**
|
|
151
|
+
* (REQUIRED) Whether to generate a doc model file.
|
|
152
|
+
*/
|
|
153
|
+
"enabled": true
|
|
154
|
+
/**
|
|
155
|
+
* The output path for the doc model file. The file extension should be ".api.json".
|
|
156
|
+
*
|
|
157
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
158
|
+
* prepend a folder token such as "<projectFolder>".
|
|
159
|
+
*
|
|
160
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
161
|
+
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
|
162
|
+
*/
|
|
163
|
+
// "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Configures how the .d.ts rollup file will be generated.
|
|
167
|
+
*/
|
|
168
|
+
"dtsRollup": {
|
|
169
|
+
/**
|
|
170
|
+
* (REQUIRED) Whether to generate the .d.ts rollup file.
|
|
171
|
+
*/
|
|
172
|
+
"enabled": true
|
|
173
|
+
/**
|
|
174
|
+
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
|
|
175
|
+
* This file will include all declarations that are exported by the main entry point.
|
|
176
|
+
*
|
|
177
|
+
* If the path is an empty string, then this file will not be written.
|
|
178
|
+
*
|
|
179
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
180
|
+
* prepend a folder token such as "<projectFolder>".
|
|
181
|
+
*
|
|
182
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
183
|
+
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
|
|
184
|
+
*/
|
|
185
|
+
// "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
|
|
186
|
+
/**
|
|
187
|
+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
|
|
188
|
+
* This file will include only declarations that are marked as "@public" or "@beta".
|
|
189
|
+
*
|
|
190
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
191
|
+
* prepend a folder token such as "<projectFolder>".
|
|
192
|
+
*
|
|
193
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
194
|
+
* DEFAULT VALUE: ""
|
|
195
|
+
*/
|
|
196
|
+
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
|
|
197
|
+
/**
|
|
198
|
+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
|
|
199
|
+
* This file will include only declarations that are marked as "@public".
|
|
200
|
+
*
|
|
201
|
+
* If the path is an empty string, then this file will not be written.
|
|
202
|
+
*
|
|
203
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
204
|
+
* prepend a folder token such as "<projectFolder>".
|
|
205
|
+
*
|
|
206
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
207
|
+
* DEFAULT VALUE: ""
|
|
208
|
+
*/
|
|
209
|
+
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
|
|
210
|
+
/**
|
|
211
|
+
* When a declaration is trimmed, by default it will be replaced by a code comment such as
|
|
212
|
+
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
|
|
213
|
+
* declaration completely.
|
|
214
|
+
*
|
|
215
|
+
* DEFAULT VALUE: false
|
|
216
|
+
*/
|
|
217
|
+
// "omitTrimmingComments": true
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* Configures how the tsdoc-metadata.json file will be generated.
|
|
221
|
+
*/
|
|
222
|
+
"tsdocMetadata": {
|
|
223
|
+
/**
|
|
224
|
+
* Whether to generate the tsdoc-metadata.json file.
|
|
225
|
+
*
|
|
226
|
+
* DEFAULT VALUE: true
|
|
227
|
+
*/
|
|
228
|
+
// "enabled": true,
|
|
229
|
+
/**
|
|
230
|
+
* Specifies where the TSDoc metadata file should be written.
|
|
231
|
+
*
|
|
232
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
233
|
+
* prepend a folder token such as "<projectFolder>".
|
|
234
|
+
*
|
|
235
|
+
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
|
|
236
|
+
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
|
|
237
|
+
* falls back to "tsdoc-metadata.json" in the package folder.
|
|
238
|
+
*
|
|
239
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
240
|
+
* DEFAULT VALUE: "<lookup>"
|
|
241
|
+
*/
|
|
242
|
+
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
|
|
246
|
+
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
|
|
247
|
+
* To use the OS's default newline kind, specify "os".
|
|
248
|
+
*
|
|
249
|
+
* DEFAULT VALUE: "crlf"
|
|
250
|
+
*/
|
|
251
|
+
// "newlineKind": "crlf",
|
|
252
|
+
/**
|
|
253
|
+
* Configures how API Extractor reports error and warning messages produced during analysis.
|
|
254
|
+
*
|
|
255
|
+
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
|
|
256
|
+
*/
|
|
257
|
+
"messages": {
|
|
258
|
+
/**
|
|
259
|
+
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
|
|
260
|
+
* the input .d.ts files.
|
|
261
|
+
*
|
|
262
|
+
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
|
|
263
|
+
*
|
|
264
|
+
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
|
265
|
+
*/
|
|
266
|
+
"compilerMessageReporting": {
|
|
267
|
+
/**
|
|
268
|
+
* Configures the default routing for messages that don't match an explicit rule in this table.
|
|
269
|
+
*/
|
|
270
|
+
"default": {
|
|
271
|
+
/**
|
|
272
|
+
* Specifies whether the message should be written to the the tool's output log. Note that
|
|
273
|
+
* the "addToApiReportFile" property may supersede this option.
|
|
274
|
+
*
|
|
275
|
+
* Possible values: "error", "warning", "none"
|
|
276
|
+
*
|
|
277
|
+
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
|
|
278
|
+
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
|
|
279
|
+
* the "--local" option), the warning is displayed but the build will not fail.
|
|
280
|
+
*
|
|
281
|
+
* DEFAULT VALUE: "warning"
|
|
282
|
+
*/
|
|
283
|
+
"logLevel": "warning"
|
|
284
|
+
/**
|
|
285
|
+
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
|
|
286
|
+
* then the message will be written inside that file; otherwise, the message is instead logged according to
|
|
287
|
+
* the "logLevel" option.
|
|
288
|
+
*
|
|
289
|
+
* DEFAULT VALUE: false
|
|
290
|
+
*/
|
|
291
|
+
// "addToApiReportFile": false
|
|
292
|
+
}
|
|
293
|
+
// "TS2551": {
|
|
294
|
+
// "logLevel": "warning",
|
|
295
|
+
// "addToApiReportFile": true
|
|
296
|
+
// },
|
|
297
|
+
//
|
|
298
|
+
// . . .
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Configures handling of messages reported by API Extractor during its analysis.
|
|
302
|
+
*
|
|
303
|
+
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
|
|
304
|
+
*
|
|
305
|
+
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
|
|
306
|
+
*/
|
|
307
|
+
"extractorMessageReporting": {
|
|
308
|
+
"default": {
|
|
309
|
+
"logLevel": "warning"
|
|
310
|
+
// "addToApiReportFile": false
|
|
311
|
+
},
|
|
312
|
+
"ae-unresolved-link": {
|
|
313
|
+
"logLevel": "none",
|
|
314
|
+
"addToApiReportFile": true
|
|
315
|
+
}
|
|
316
|
+
// "ae-extra-release-tag": {
|
|
317
|
+
// "logLevel": "warning",
|
|
318
|
+
// "addToApiReportFile": true
|
|
319
|
+
// },
|
|
320
|
+
//
|
|
321
|
+
// . . .
|
|
322
|
+
},
|
|
323
|
+
/**
|
|
324
|
+
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
|
|
325
|
+
*
|
|
326
|
+
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
|
|
327
|
+
*
|
|
328
|
+
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
|
329
|
+
*/
|
|
330
|
+
"tsdocMessageReporting": {
|
|
331
|
+
"default": {
|
|
332
|
+
"logLevel": "warning"
|
|
333
|
+
// "addToApiReportFile": false
|
|
334
|
+
}
|
|
335
|
+
// "tsdoc-link-tag-unescaped-text": {
|
|
336
|
+
// "logLevel": "warning",
|
|
337
|
+
// "addToApiReportFile": true
|
|
338
|
+
// },
|
|
339
|
+
//
|
|
340
|
+
// . . .
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Disable colors in Jest to ensure consistent snapshot behavior
|
|
2
|
+
// This setup file ensures that Jest matchers don't include ANSI color codes
|
|
3
|
+
// in their output, which was causing snapshot test failures when running
|
|
4
|
+
// via different environments (direct Jest vs Heft/Rush)
|
|
5
|
+
|
|
6
|
+
// Force Jest to not use colors
|
|
7
|
+
process.env.FORCE_COLOR = '0';
|
|
8
|
+
|
|
9
|
+
// Monkey patch the jest-matcher-utils functions to remove colors
|
|
10
|
+
const matcherUtils = require('jest-matcher-utils');
|
|
11
|
+
|
|
12
|
+
// Store original functions
|
|
13
|
+
const originalPrintExpected = matcherUtils.printExpected;
|
|
14
|
+
const originalPrintReceived = matcherUtils.printReceived;
|
|
15
|
+
const originalMatcherHint = matcherUtils.matcherHint;
|
|
16
|
+
|
|
17
|
+
// Override with non-colored versions
|
|
18
|
+
matcherUtils.printExpected = function (value) {
|
|
19
|
+
// Remove ANSI color codes from the output
|
|
20
|
+
const result = originalPrintExpected.call(this, value);
|
|
21
|
+
return result.replace(/\x1b\[[0-9;]*m/g, '');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
matcherUtils.printReceived = function (value) {
|
|
25
|
+
// Remove ANSI color codes from the output
|
|
26
|
+
const result = originalPrintReceived.call(this, value);
|
|
27
|
+
return result.replace(/\x1b\[[0-9;]*m/g, '');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
matcherUtils.matcherHint = function (matcherName, received, expected, options) {
|
|
31
|
+
// Remove ANSI color codes from the output
|
|
32
|
+
const result = originalMatcherHint.call(this, matcherName, received, expected, options);
|
|
33
|
+
return result.replace(/\x1b\[[0-9;]*m/g, '');
|
|
34
|
+
};
|
package/config/rig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The "rig.json" file directs tools to look for their config files in an external package.
|
|
2
|
+
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
|
3
|
+
{
|
|
4
|
+
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
|
5
|
+
/**
|
|
6
|
+
* (Required) The name of the rig package to inherit from.
|
|
7
|
+
* It should be an NPM package name with the "-rig" suffix.
|
|
8
|
+
*/
|
|
9
|
+
"rigPackageName": "@rushstack/heft-node-rig"
|
|
10
|
+
/**
|
|
11
|
+
* (Optional) Selects a config profile from the rig package. The name must consist of
|
|
12
|
+
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
|
13
|
+
* If omitted, then the "default" profile will be used."
|
|
14
|
+
*/
|
|
15
|
+
// "rigProfile": "your-profile-name"
|
|
16
|
+
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const jest_snapshot_1 = require("jest-snapshot");
|
|
5
5
|
const predicate_1 = require("./predicate");
|
|
6
6
|
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
7
|
+
const colorHelpers_1 = require("../../utils/colorHelpers");
|
|
7
8
|
exports.default = {
|
|
8
9
|
toFailTestAndMatchSnapshot: function (cb) {
|
|
9
10
|
const context = this;
|
|
@@ -20,7 +21,7 @@ exports.default = {
|
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
return jest_snapshot_1.toMatchSnapshot.call(context, cbResult.value, 'toFailTestAndMatchSnapshot');
|
|
24
|
+
return jest_snapshot_1.toMatchSnapshot.call(context, (0, colorHelpers_1.stripAnsiColors)(cbResult.value), 'toFailTestAndMatchSnapshot');
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for handling ANSI color codes in test output.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Strips ANSI color/style escape sequences from a string.
|
|
8
|
+
*
|
|
9
|
+
* This function removes all ANSI escape sequences commonly used for
|
|
10
|
+
* terminal colors and text styling, making the output suitable for
|
|
11
|
+
* color-agnostic snapshot testing.
|
|
12
|
+
*
|
|
13
|
+
* @param text - The text that may contain ANSI escape sequences
|
|
14
|
+
* @returns The text with all ANSI escape sequences removed
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const coloredText = '\u001b[31mError:\u001b[39m Something failed';
|
|
19
|
+
* const plainText = stripAnsiColors(coloredText);
|
|
20
|
+
* console.log(plainText); // "Error: Something failed"
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Common usage in Jest matchers
|
|
26
|
+
* const formattedOutput = matcherUtils.printReceived(value);
|
|
27
|
+
* const cleanOutput = stripAnsiColors(formattedOutput);
|
|
28
|
+
* expect(cleanOutput).toMatchSnapshot();
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare function stripAnsiColors(text: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a wrapper function that strips ANSI colors from any string-returning function.
|
|
36
|
+
*
|
|
37
|
+
* This is useful for wrapping Jest matcher utility functions to make them
|
|
38
|
+
* color-agnostic for snapshot testing.
|
|
39
|
+
*
|
|
40
|
+
* @param fn - A function that returns a string (potentially with ANSI colors)
|
|
41
|
+
* @returns A wrapped function that returns the same string with colors stripped
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { printReceived } from 'jest-matcher-utils';
|
|
46
|
+
*
|
|
47
|
+
* const printReceivedClean = createColorStripWrapper(printReceived);
|
|
48
|
+
* const output = printReceivedClean(someValue); // No colors
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare function createColorStripWrapper<T extends (...args: unknown[]) => string>(fn: T): T;
|
|
54
|
+
//# sourceMappingURL=colorHelpers.d.ts.map
|