ng test
執行某個專案中的單元測試。
Runs unit tests in a project.
ng test <project> [options]
ng t <project> [options]
說明
獲取在工作空間配置檔案 angular.json
的 projects
部分指定的專案名稱。如果未提供專案名稱,它將對所有專案執行。
Takes the name of the project, as specified in the projects
section of the angular.json
workspace configuration file. When a project name is not supplied, it will execute for all projects.
引數
引數 | 說明 |
---|---|
<project> | 要建構的專案名。可以是應用或函式庫。 The name of the project to build. Can be an application or a library. |
選項
選項 | 說明 |
---|---|
--browsers=browsers | 覆蓋要針對哪些瀏覽器執行測試。 Override which browsers tests are run against. |
--code-coverage=true|false | 輸出程式碼覆蓋率報告。 Output a code coverage report. 預設值: |
--code-coverage-exclude | 排除在程式碼覆蓋範圍之外的 glob。 Globs to exclude from code coverage. |
--configuration=configuration | 建構器的一個或多個命名配置,是一個逗號分隔的列表,就像在 angular.json 的 "configurations" 部分指定的一樣。 建構器使用這些命名配置執行給定的目標。 欲知詳情,參見 https://angular.cn/guide/workspace-config#alternate-build-configurations。 可以透過顯式指定 "--prod" 標誌來覆蓋它。 One or more named builder configurations as a comma-separated list as specified in the "configurations" section of angular.json. The builder uses the named configurations to run the given target. For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations. Setting this explicitly overrides the "--prod" flag. 別名: -c |
--help= | 在控制檯顯示關於本命令的幫助資訊。 Shows a help message for this command in the console. 預設值: |
--include | 要包含的檔案的 glob,是相對於工作空間或專案根目錄的。 有兩個特例: Globs of files to include, relative to workspace or project root. There are 2 special cases:
|
--karma-config=karma-config | Karma 配置檔案的名稱。 The name of the Karma configuration file. |
--main=main | 主入口點檔案的名稱。 The name of the main entry-point file. |
--poll | 啟用並定義檔案監視輪詢間隔(以毫秒為單位)。 Enable and define the file watching poll time period in milliseconds. |
--polyfills=polyfills | polyfills 檔案的名稱。 The name of the polyfills file. |
--preserve-symlinks=true|false | 當解析模組時,不要使用真實路徑。如果未設定,則如果 NodeJS 啟用了 --preserve-symlinks 選項,就預設為 Do not use the real path when resolving modules. If unset then will default to |
--prod=true|false | "--configuration=production" 的簡寫形式。 把建構配置的目標設定為產品環境。 預設情況下,產品環境目標是在工作空間配置中設定的,可以設定打包方式、搖樹優化限制、死程式碼移除限制等方面。 Shorthand for "--configuration=production". Set the build configuration to the production target. By default, the production target is set up in the workspace configuration such that all builds make use of bundling, limited tree-shaking, and also limited dead code elimination. |
--progress=true|false | 在建構時將進度記錄到控制檯。 Log progress to the console while building. 預設值: |
--reporters | 要使用的 Karma 彙報器。直接傳給 Karma 執行器。 Karma reporters to use. Directly passed to the karma runner. |
--source-map=true|false | 輸出指令碼和樣式的原始碼對映資訊。欲知詳情,請參閱https://angular.cn/guide/workspace-config#source-map-configuration。 Output source maps for scripts and styles. For more information, see https://angular.io/guide/workspace-config#source-map-configuration. 預設值: |
--ts-config=ts-config | TypeScript 配置檔案的名稱。 The name of the TypeScript configuration file. |
--watch=true|false | 當檔案更改時執行建構。 Run build when files change. |
--web-worker-ts-config= | Web Worker 模組的 TypeScript 配置。 TypeScript configuration for Web Worker modules. |