|
| 1 | +{ |
| 2 | + "$schema": "http://json-schema.org/draft-07/schema", |
| 3 | + "title": "Schema for Nx Unit Test Executor", |
| 4 | + "description": "Run application unit tests. _Note: this is only supported in Angular versions >= 21.0.0_.", |
| 5 | + "outputCapture": "direct-nodejs", |
| 6 | + "type": "object", |
| 7 | + "properties": { |
| 8 | + "buildTarget": { |
| 9 | + "type": "string", |
| 10 | + "description": "Specifies the build target to use for the unit test build in the format `project:target[:configuration]`. This defaults to the `build` target of the current project with the `development` configuration. You can also pass a comma-separated list of configurations. Example: `project:target:production,staging`.", |
| 11 | + "pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$" |
| 12 | + }, |
| 13 | + "tsConfig": { |
| 14 | + "type": "string", |
| 15 | + "description": "The path to the TypeScript configuration file, relative to the workspace root. Defaults to `tsconfig.spec.json` in the project root if it exists. If not specified and the default does not exist, the `tsConfig` from the specified `buildTarget` will be used." |
| 16 | + }, |
| 17 | + "runner": { |
| 18 | + "type": "string", |
| 19 | + "description": "Specifies the test runner to use for test execution.", |
| 20 | + "default": "vitest", |
| 21 | + "enum": ["karma", "vitest"] |
| 22 | + }, |
| 23 | + "runnerConfig": { |
| 24 | + "type": ["string", "boolean"], |
| 25 | + "description": "Specifies the configuration file for the selected test runner. If a string is provided, it will be used as the path to the configuration file. If `true`, the builder will search for a default configuration file (e.g., `vitest.config.ts` or `karma.conf.js`). If `false`, no external configuration file will be used.\\nFor Vitest, this enables advanced options and the use of custom plugins. Please note that while the file is loaded, the Angular team does not provide direct support for its specific contents or any third-party plugins used within it.", |
| 26 | + "default": false |
| 27 | + }, |
| 28 | + "browsers": { |
| 29 | + "description": "Specifies the browsers to use for test execution. When not specified, tests are run in a Node.js environment using jsdom. For both Vitest and Karma, browser names ending with 'Headless' (e.g., 'ChromeHeadless') will enable headless mode.", |
| 30 | + "type": "array", |
| 31 | + "items": { |
| 32 | + "type": "string" |
| 33 | + }, |
| 34 | + "minItems": 1 |
| 35 | + }, |
| 36 | + "browserViewport": { |
| 37 | + "description": "Specifies the browser viewport dimensions for browser-based tests in the format `widthxheight`.", |
| 38 | + "type": "string", |
| 39 | + "pattern": "^\\d+x\\d+$" |
| 40 | + }, |
| 41 | + "include": { |
| 42 | + "type": "array", |
| 43 | + "items": { |
| 44 | + "type": "string" |
| 45 | + }, |
| 46 | + "default": ["**/*.spec.ts", "**/*.test.ts"], |
| 47 | + "description": "Specifies glob patterns of files to include for testing, relative to the project root. This option also has special handling for directory paths (includes all test files within) and file paths (includes the corresponding test file if one exists)." |
| 48 | + }, |
| 49 | + "exclude": { |
| 50 | + "type": "array", |
| 51 | + "items": { |
| 52 | + "type": "string" |
| 53 | + }, |
| 54 | + "description": "Specifies glob patterns of files to exclude from testing, relative to the project root." |
| 55 | + }, |
| 56 | + "filter": { |
| 57 | + "type": "string", |
| 58 | + "description": "Specifies a regular expression pattern to match against test suite and test names. Only tests with a name matching the pattern will be executed. For example, `^App` will run only tests in suites beginning with 'App'." |
| 59 | + }, |
| 60 | + "watch": { |
| 61 | + "type": "boolean", |
| 62 | + "description": "Enables watch mode, which re-runs tests when source files change. Defaults to `true` in TTY environments and `false` otherwise." |
| 63 | + }, |
| 64 | + "debug": { |
| 65 | + "type": "boolean", |
| 66 | + "description": "Enables debugging mode for tests, allowing the use of the Node Inspector.", |
| 67 | + "default": false |
| 68 | + }, |
| 69 | + "ui": { |
| 70 | + "type": "boolean", |
| 71 | + "description": "Enables the Vitest UI for interactive test execution. This option is only available for the Vitest runner.", |
| 72 | + "default": false |
| 73 | + }, |
| 74 | + "coverage": { |
| 75 | + "type": "boolean", |
| 76 | + "description": "Enables coverage reporting for tests.", |
| 77 | + "default": false |
| 78 | + }, |
| 79 | + "coverageInclude": { |
| 80 | + "type": "array", |
| 81 | + "description": "Specifies glob patterns of files to include in the coverage report.", |
| 82 | + "items": { |
| 83 | + "type": "string" |
| 84 | + } |
| 85 | + }, |
| 86 | + "coverageExclude": { |
| 87 | + "type": "array", |
| 88 | + "description": "Specifies glob patterns of files to exclude from the coverage report.", |
| 89 | + "items": { |
| 90 | + "type": "string" |
| 91 | + } |
| 92 | + }, |
| 93 | + "coverageReporters": { |
| 94 | + "type": "array", |
| 95 | + "description": "Specifies the reporters to use for coverage results. Each reporter can be a string representing its name, or a tuple containing the name and an options object. Built-in reporters include 'html', 'lcov', 'lcovonly', 'text', 'text-summary', 'cobertura', 'json', and 'json-summary'.", |
| 96 | + "items": { |
| 97 | + "oneOf": [ |
| 98 | + { |
| 99 | + "enum": [ |
| 100 | + "html", |
| 101 | + "lcov", |
| 102 | + "lcovonly", |
| 103 | + "text", |
| 104 | + "text-summary", |
| 105 | + "cobertura", |
| 106 | + "json", |
| 107 | + "json-summary" |
| 108 | + ] |
| 109 | + }, |
| 110 | + { |
| 111 | + "type": "array", |
| 112 | + "minItems": 1, |
| 113 | + "maxItems": 2, |
| 114 | + "items": [ |
| 115 | + { |
| 116 | + "enum": [ |
| 117 | + "html", |
| 118 | + "lcov", |
| 119 | + "lcovonly", |
| 120 | + "text", |
| 121 | + "text-summary", |
| 122 | + "cobertura", |
| 123 | + "json", |
| 124 | + "json-summary" |
| 125 | + ] |
| 126 | + }, |
| 127 | + { |
| 128 | + "type": "object" |
| 129 | + } |
| 130 | + ] |
| 131 | + } |
| 132 | + ] |
| 133 | + } |
| 134 | + }, |
| 135 | + "coverageThresholds": { |
| 136 | + "type": "object", |
| 137 | + "description": "Specifies minimum coverage thresholds that must be met. If thresholds are not met, the builder will exit with an error.", |
| 138 | + "properties": { |
| 139 | + "perFile": { |
| 140 | + "type": "boolean", |
| 141 | + "description": "When true, thresholds are enforced for each file individually." |
| 142 | + }, |
| 143 | + "statements": { |
| 144 | + "type": "number", |
| 145 | + "description": "Minimum percentage of statements covered." |
| 146 | + }, |
| 147 | + "branches": { |
| 148 | + "type": "number", |
| 149 | + "description": "Minimum percentage of branches covered." |
| 150 | + }, |
| 151 | + "functions": { |
| 152 | + "type": "number", |
| 153 | + "description": "Minimum percentage of functions covered." |
| 154 | + }, |
| 155 | + "lines": { |
| 156 | + "type": "number", |
| 157 | + "description": "Minimum percentage of lines covered." |
| 158 | + } |
| 159 | + }, |
| 160 | + "additionalProperties": false |
| 161 | + }, |
| 162 | + "coverageWatermarks": { |
| 163 | + "type": "object", |
| 164 | + "description": "Specifies coverage watermarks for the HTML reporter. These determine the color coding for high, medium, and low coverage.", |
| 165 | + "properties": { |
| 166 | + "statements": { |
| 167 | + "type": "array", |
| 168 | + "description": "The high and low watermarks for statements coverage. `[low, high]`", |
| 169 | + "items": { "type": "number" }, |
| 170 | + "minItems": 2, |
| 171 | + "maxItems": 2 |
| 172 | + }, |
| 173 | + "branches": { |
| 174 | + "type": "array", |
| 175 | + "description": "The high and low watermarks for branches coverage. `[low, high]`", |
| 176 | + "items": { "type": "number" }, |
| 177 | + "minItems": 2, |
| 178 | + "maxItems": 2 |
| 179 | + }, |
| 180 | + "functions": { |
| 181 | + "type": "array", |
| 182 | + "description": "The high and low watermarks for functions coverage. `[low, high]`", |
| 183 | + "items": { "type": "number" }, |
| 184 | + "minItems": 2, |
| 185 | + "maxItems": 2 |
| 186 | + }, |
| 187 | + "lines": { |
| 188 | + "type": "array", |
| 189 | + "description": "The high and low watermarks for lines coverage. `[low, high]`", |
| 190 | + "items": { "type": "number" }, |
| 191 | + "minItems": 2, |
| 192 | + "maxItems": 2 |
| 193 | + } |
| 194 | + }, |
| 195 | + "additionalProperties": false |
| 196 | + }, |
| 197 | + "reporters": { |
| 198 | + "type": "array", |
| 199 | + "description": "Specifies the reporters to use during test execution. Each reporter can be a string representing its name, or a tuple containing the name and an options object. Built-in reporters include 'default', 'verbose', 'dots', 'json', 'junit', 'tap', 'tap-flat', and 'html'. You can also provide a path to a custom reporter.", |
| 200 | + "items": { |
| 201 | + "oneOf": [ |
| 202 | + { |
| 203 | + "anyOf": [ |
| 204 | + { |
| 205 | + "type": "string" |
| 206 | + }, |
| 207 | + { |
| 208 | + "enum": [ |
| 209 | + "default", |
| 210 | + "verbose", |
| 211 | + "dots", |
| 212 | + "json", |
| 213 | + "junit", |
| 214 | + "tap", |
| 215 | + "tap-flat", |
| 216 | + "html" |
| 217 | + ] |
| 218 | + } |
| 219 | + ] |
| 220 | + }, |
| 221 | + { |
| 222 | + "type": "array", |
| 223 | + "minItems": 1, |
| 224 | + "maxItems": 2, |
| 225 | + "items": [ |
| 226 | + { |
| 227 | + "anyOf": [ |
| 228 | + { |
| 229 | + "type": "string" |
| 230 | + }, |
| 231 | + { |
| 232 | + "enum": [ |
| 233 | + "default", |
| 234 | + "verbose", |
| 235 | + "dots", |
| 236 | + "json", |
| 237 | + "junit", |
| 238 | + "tap", |
| 239 | + "tap-flat", |
| 240 | + "html" |
| 241 | + ] |
| 242 | + } |
| 243 | + ] |
| 244 | + }, |
| 245 | + { |
| 246 | + "type": "object" |
| 247 | + } |
| 248 | + ] |
| 249 | + } |
| 250 | + ] |
| 251 | + } |
| 252 | + }, |
| 253 | + "outputFile": { |
| 254 | + "type": "string", |
| 255 | + "description": "Specifies a file path for the test report, applying only to the first reporter. To configure output files for multiple reporters, use the tuple format `['reporter-name', { outputFile: '...' }]` within the `reporters` option. When not provided, output is written to the console." |
| 256 | + }, |
| 257 | + "providersFile": { |
| 258 | + "type": "string", |
| 259 | + "description": "Specifies the path to a TypeScript file that provides an array of Angular providers for the test environment. The file must contain a default export of the provider array.", |
| 260 | + "minLength": 1 |
| 261 | + }, |
| 262 | + "setupFiles": { |
| 263 | + "type": "array", |
| 264 | + "items": { |
| 265 | + "type": "string" |
| 266 | + }, |
| 267 | + "description": "A list of paths to global setup files that are executed before the test files. The application's polyfills and the Angular TestBed are always initialized before these files." |
| 268 | + }, |
| 269 | + "progress": { |
| 270 | + "type": "boolean", |
| 271 | + "description": "Shows build progress information in the console. Defaults to the `progress` setting of the specified `buildTarget`." |
| 272 | + }, |
| 273 | + "listTests": { |
| 274 | + "type": "boolean", |
| 275 | + "description": "Lists all discovered test files and exits the process without building or executing the tests.", |
| 276 | + "default": false |
| 277 | + }, |
| 278 | + "dumpVirtualFiles": { |
| 279 | + "type": "boolean", |
| 280 | + "description": "Dumps build output files to the `.angular/cache` directory for debugging purposes.", |
| 281 | + "default": false, |
| 282 | + "visible": false |
| 283 | + }, |
| 284 | + "plugins": { |
| 285 | + "description": "A list of ESBuild plugins.", |
| 286 | + "type": "array", |
| 287 | + "items": { |
| 288 | + "oneOf": [ |
| 289 | + { |
| 290 | + "type": "object", |
| 291 | + "properties": { |
| 292 | + "path": { |
| 293 | + "type": "string", |
| 294 | + "description": "The path to the plugin. Relative to the workspace root." |
| 295 | + }, |
| 296 | + "options": { |
| 297 | + "type": "object", |
| 298 | + "description": "The options to provide to the plugin.", |
| 299 | + "properties": {}, |
| 300 | + "additionalProperties": true |
| 301 | + } |
| 302 | + }, |
| 303 | + "additionalProperties": false, |
| 304 | + "required": ["path"] |
| 305 | + }, |
| 306 | + { |
| 307 | + "type": "string", |
| 308 | + "description": "The path to the plugin. Relative to the workspace root." |
| 309 | + } |
| 310 | + ] |
| 311 | + } |
| 312 | + }, |
| 313 | + "indexHtmlTransformer": { |
| 314 | + "description": "Path to a file exposing a default function to transform the `index.html` file.", |
| 315 | + "type": "string" |
| 316 | + } |
| 317 | + }, |
| 318 | + "additionalProperties": false, |
| 319 | + "required": [] |
| 320 | +} |
0 commit comments