src/enironments/environment.docker.ts
当我运行我的 e2e 测试的 dockerized 版本时,我想选择文件。
我在 angular.json 中添加了一个新的 e2e 部分
"myapp-e2e": {
...
},
"myapp-e2e-docker": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "myapp:serve:docker"
}
}
}
我在我的服务部分添加了一个配置:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "myapp:build"
},
"configurations": {
"production": {
"browserTarget": "myapp:build:production"
},
"docker": {
"browserTarget": "myapp:build:docker"
}
}
}
以及我的构建部分的配置:
"docker": {
...
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.docker.ts"
}
]
}
然后我像这样调用我的 e2e conf
ng e2e myapp-e2e-docker
它似乎符合我的预期。例如,如果我拼错了 environment.docker.ts 文件的名称,它会抱怨找不到它。但是,在运行时阅读环境的内容,我总是从src/environments/environment.ts
这是某种错误吗?看起来该ng serve
设施的功能不适用于ng e2e
.
我的 package.json 文件:
"devDependencies": {
"@angular-devkit/build-angular": "0.12.1",
"@angular/language-service": "6.1.0",
"@types/jasmine": "3.0.0",
"@types/jasminewd2": "2.0.6",
"@types/node": "6.0.60",
"codelyzer": "4.2.1",
"jasmine-core": "3.3.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "3.1.1",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "2.0.4",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.0",
"protractor": "5.3.0",
"ts-node": "7.0.1",
"tslint": "5.3.2",
"typescript": "2.9.2"
}