1

我们刚刚完成了对 Angular 7 的升级,从那时起,我们尝试运行 e2e 测试时它什么也没做。它不会抛出任何错误,只是什么都不做。

我尝试启动一个全新的 Angular 项目,并且 e2e 测试在那里运行良好。我复制了他们的 angular.json 文件,只是替换了路径,它做同样的事情。

其他一切都完美无缺。单元测试、服务和 aot 构建。

E2e输出

角.json:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "lscloud-ui": {
            "root": "",
            "sourceRoot": "source",
            "projectType": "application",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "build/build",
                        "index": "source/index.html",
                        "main": "source/main.ts",
                        "tsConfig": "source/tsconfig.app.json",
                        "showCircularDependencies": false,
                        "polyfills": "source/polyfills.ts",
                        "assets": [
                            "source/assets",
                            "source/favicon.ico"
                        ],
                        "styles": [],
                        "scripts": []
                    },
                    "configurations": {
                        "production": {
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "extractCss": true,
                            "namedChunks": false,
                            "aot": true,
                            "extractLicenses": true,
                            "vendorChunk": false,
                            "buildOptimizer": true,
                            "fileReplacements": [
                                {
                                    "replace": "source/environments/environment.ts",
                                    "with": "source/environments/environment.prod.ts"
                                }
                            ]
                        }
                    }
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "options": {
                        "browserTarget": "lscloud-ui:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "lscloud-ui:build:production"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "lscloud-ui:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "main": "source/test.ts",
                        "karmaConfig": "./karma.conf.js",
                        "polyfills": "source/polyfills.ts",
                        "tsConfig": "source/tsconfig.spec.json",
                        "scripts": [],
                        "styles": [],
                        "assets": [
                            "source/assets",
                            "source/favicon.ico"
                        ]
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "source/tsconfig.app.json"
                        ],
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        },
        "lscloud-ui-e2e": {
            "root": "",
            "sourceRoot": "",
            "projectType": "application",
            "architect": {
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "./protractor.conf.js",
                        "devServerTarget": "lscloud-ui:serve",
                        "port": 49152
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "lscloud-ui:serve:production"
                        }
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "e2e/tsconfig.e2e.json"
                        ],
                        "exclude": []
                    }
                }
            }
        }
    },
    "defaultProject": "lscloud-ui",
    "schematics": {
        "@schematics/angular:component": {
            "prefix": "",
            "styleext": "css"
        },
        "@schematics/angular:directive": {
            "prefix": ""
        }
    }
}

量角器.conf.js

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
    allScriptsTimeout: 11000,
    specs: [
        './e2e/**/*.e2e-spec.ts'
    ],
    capabilities: {
        'browserName': 'chrome'
    },
    directConnect: true,
    baseUrl: 'http://localhost:8081/',
    framework: 'jasmine',
    // capabilities: {
    //   'browserName': 'chrome',
    //   'chromeOptions': {
    //     'args': [ "--headless", "--disable-gpu", "--window-size=800x600" ]
    //   }
    // },
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function () { }
    },
    onPrepare() {
        browser.manage().window().setSize(1920, 1080);
        browser.ignoreSynchronization = true;
        require('ts-node').register({
            project: 'e2e/tsconfig.e2e.json'
        });
        jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    },
    // seleniumAddress: 'http://localhost:4444/wd/hub',
    // seleniumSessionId: '82d468f7f7336afd5727cd8682c252eb',

    SELENIUM_PROMISE_MANAGER: false,
};
4

0 回答 0