所以,這是一個可怕的黑客攻擊。這種暗示暗示某事是深刻的錯誤,但ho-hum:
當ng serve runs 它將改變控制檯窗口標題爲「angular-cli」,當gulp運行它將它改爲「gulp 「(或」選擇吞嚥「)。我不希望別的東西會與這些標題一起運行。 這足以寫入__kill-running-windows
去殺掉這些窗口。
包。JSON:
"scripts": {
"start": "ng serve -prod",
"test": "gulp test-teamcity",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"gulp": "gulp",
"e2e-teamcity": "gulp _e2e-clean && npm run _e2e-teamcity & npm run _kill-running-windows",
"_e2e-teamcity": "npm run _e2e-servers && gulp __wait-60 && gulp _e2e-test-teamcity",
"_e2e-servers": "start gulp _e2e-server && start gulp serve",
"_kill-running-windows": "taskkill /fi \"Windowtitle eq gulp\" & taskkill /fi \"Windowtitle eq select gulp\" & taskkill /fi \"Windowtitle eq angular-cli\" & taskkill /fi \"Windowtitle eq select angular-cli\""
},
代碼(有趣的部分,無論如何,我會留下什麼如一飲而盡有助於讀者的想象):
var expressServer = require("gulp-express");
var process = require("child_process");
var shell = require("gulp-shell");
/**
* Run vanilla e2e tests with teamcity reporter
*
* (Remember to call `e2e-server`, `serve` and edit `config.json` to point at config.e2e.json` first)
*/
gulp.task("_e2e-test-teamcity", function(done) {
return gulp.src("")
.pipe(
shell(["npm run e2e -- e2e/protractor-teamcity.conf.js"])
)
});
gulp.task("__wait-60", function(done) {
// HACK: Do 61 pings -> wait 30 seconds
process.exec("ping 127.0.0.1 -n 61 > nul", function (err, stdout, stderr) {
done();
});
});
/**
* Run mock backend for the e2e, with canned answers to all calls
* !! Use config.e2e.json in your application in order to point at this !!
*/
gulp.task("_e2e-server", function() {
expressServer.run(["./e2e/server.js"]);
gulp.watch(["./e2e/server.js"], expressServer.notify);
});
出於某種原因,移動更多的代碼到一飲而盡似乎讓構建永遠不會在團隊中完成。但這裏是我在本地使用的e2e,這是更多的gulp的基礎:
/**
* Run vanilla e2e tests
* Cleans screenshots folder, tarts the application, starts the mock server
* Leaves command windows running the servers open at the end of the test run
*
* 30 second wait for tests to start
*
* (Remember to edit `config.json` to point at config.e2e.json` first)
*/
gulp.task("e2e", ["_e2e-clean"], function (done) {
gulp.src("")
.pipe(
shell(["start gulp _e2e-server"])
).pipe(
shell(["start gulp serve"])
);
runSequence("__wait-30","_e2e-test", done);
});
這不是所有的時間,我真的希望我能想到另一種方式來做到這一點。 –