小编rea*_*lex的帖子

在 angular 7 中为 ng e2e 测试设置特定环境而不为应用程序提供服务

我最近将我的应用程序升级到了 angular 7。我正在尝试使用特定环境运行我的 ng e2e 测试。此外,我不希望每次为应用程序运行 e2e 测试时都运行新服务器。

使用 angular 5 时,我曾经使用 CLI 按照以下方式进行操作:

ng e2e -e test --config protractor.conf.test.js --no-serve
Run Code Online (Sandbox Code Playgroud)

我的测试环境在 environment.test.ts 文件中设置,量角器配置(baseURL 和无头浏览器)在 protractor.conf.test.js 文件中设置。每次运行 e2e 测试时,我都使用 no-serve 标志停止运行新服务器。

对于 angular 7,我在 angular.json 文件中进行了以下更改:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "sample-app": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": ["src/assets", "src/favicon.ico"],
            "styles": ["src/styles.css"],
            "scripts": []
          },
          "configurations": …
Run Code Online (Sandbox Code Playgroud)

e2e-testing angular angular7 angular-cli-v7

5
推荐指数
1
解决办法
1948
查看次数

标签 统计

angular ×1

angular-cli-v7 ×1

angular7 ×1

e2e-testing ×1