📅  最后修改于: 2020-10-27 02:43:07             🧑  作者: Mango
ng e2e [options]
ng e [options]
ng e2e会构建,为应用程序提供服务,然后使用量角器运行端到端的测试用例。选项是可选参数。
Sr.No. | Argument & Syntax | Description |
---|---|---|
1 | The name of the project to test. |
Sr.No. | Option & Syntax | Description |
---|---|---|
1 | –baseUrl=baseUrl | Base URL for protractor to connect to. |
2 | –configuration=configuration |
A named build target, as specified in the “configurations” section of angular.json. Each named target is accompanied by a configuration of option defaults for that target. Setting this explicitly overrides the “–prod” flag Aliases: -c |
3 | –devServerTarget=devServerTarget | Dev server target to run tests against. |
4 | –grep=grep | Execute specs whose names match the pattern, which is internally compiled to a RegExp. |
5 | –help=true|false|json|JSON |
Shows a help message for this command in the console. Default: false |
6 | –host=host | Host to listen on. |
7 | –invertGrep=true|false |
Invert the selection specified by the ‘grep’ option. Default: false |
8 | –port | The port to use to serve the application. |
9 | –prod=true|false | Shorthand for “–configuration=production”. When true, sets 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. |
10 | –protractorConfig=protractorConfig | The name of the Protractor configuration file. |
11 | –specs | Override specs in the protractor config. |
12 | –suite=suite | Override suite in the protractor config. |
13 | –webdriverUpdate=true|false |
Try to update webdriver. Default: true |
首先转到使用ng build命令更新的角度项目。
现在运行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
{{ title }} app is running!
现在运行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运行验收测试用例。