Angular CLI-nge2eコマンド

構文

ng e2e <project> [options]
ng e <project> [options]

ng e2eは、アプリケーションをビルドして提供し、分度器を使用してエンドツーエンドのテストケースを実行します。オプションはオプションのパラメータです。

引数

シニア番号 引数と構文 説明
1 <プロジェクト> テストするプロジェクトの名前。

オプション

シニア番号 オプションと構文 説明
1 --baseUrl = baseUrl 分度器が接続するベースURL。
2 --configuration = configuration

angle.jsonの「構成」セクションで指定されている名前付きビルドターゲット。名前付きの各ターゲットには、そのターゲットのオプションのデフォルトの構成が付属しています。これを明示的に設定すると、「-prod」フラグが上書きされます

エイリアス:-c

3 --devServerTarget = devServerTarget テストを実行する開発サーバーターゲット。
4 --grep = grep 名前がパターンと一致するスペックを実行します。パターンは、内部でRegExpにコンパイルされます。
5 --help = true | false | json | JSON

このコマンドのヘルプメッセージをコンソールに表示します。

デフォルト:false

6 --host = host 聞くホスト。
7 --invertGrep = true | false

'grep'オプションで指定された選択を反転します。

デフォルト:false

8 - 港 アプリケーションを提供するために使用するポート。
9 --prod = true | false 「--configuration = production」の省略形。trueの場合、ビルド構成を本番ターゲットに設定します。デフォルトでは、本番ターゲットはワークスペース構成で設定されているため、すべてのビルドでバンドル、制限されたツリーシェイク、および制限されたデッドコードの除去が利用されます。
10 --protractorConfig = protractorConfig 分度器構成ファイルの名前。
11 -仕様 分度器構成の仕様を上書きします。
12 --suite = suite 分度器構成のスイートをオーバーライドします。
13 --webdriverUpdate = true | false

webdriverを更新してみてください。

デフォルト:true

使用して更新された角度のプロジェクトへの最初の移動ngのビルドコマンドを。

次に、e2eコマンドを実行します。

\>Node\>TutorialsPoint> ng e2e
...
chunk {main} main.js, main.js.map (main) 14.3 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 141 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 12.4 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3 MB [initial] [rendered]
Date: 2020-06-06T04:20:15.029Z - Hash: 16f321e3d4599af26622 - Time: 20899ms
** Angular Live Development Server is listening on localhost:4200, open your bro
wser on http://localhost:4200/ **
: Compiled successfully.
...
   workspace-project App
    x should display welcome message
      - Failed: No element found using locator: By(css selector, app-root .content span)
   ...
      From: Task: Run it("should display welcome message") in control flow
   ...
**************************************************
*                    Failures                    *
**************************************************

1) workspace-project App should display welcome message
  - Failed: No element found using locator: By(css selector, app-root .content span)

Executed 1 of 1 spec (1 FAILED) in 2 secs.

失敗を修正するには、app.component.htmlを更新します

app.component.html

<div class="content" role="main">
   <span>{{ title }} app is running!</span>
</div>
<app-goals></app-goals>
<router-outlet></router-outlet>

次に、e2eコマンドを実行します。

\>Node\>TutorialsPoint> ng e2e
...
chunk {main} main.js, main.js.map (main) 14.9 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 141 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 12.4 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3 MB [initial] [rendered]
Date: 2020-06-06T04:28:33.514Z - Hash: 5d8bf2fc7ff59fa390b0 - Time: 10529ms
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
: Compiled successfully.
...
   workspace-project App
      √ should display welcome message

Executed 1 of 1 spec SUCCESS in 2 secs.

ng e2eはブラウザを開き、それを使用してUIを使用して受け入れテストケースを実行します。