私の開発ワークフローでは、私がnpm start task
を実行するための2つのターミナルウィンドウを開いて、サーバが2番目のウィンドウで動作していれば、テストスイートとこれは私が期待どおりに働いた。しかし、私の問題は、私のCI環境では、これを1つのプロセスで実行する必要があるということです。これに伴う問題は、タスクのNPM開始の実行のためにしばらく時間がかかると同時に、キュウリのタスクがローカルホストへのアクセスを試みるあるWebpack dev server:サーバが実行中であることをトリガーコマンドのためのフックまたはメカニズム
npm start | cucumberjs --require test/functional/ --compiler js:babel-register test/functional/
:3000(URL私はこれをしようとしてきましたwebpack-dev-serverが実行されているとき)、サーバーはまだ準備ができておらず、テストは失敗します。
私はこれにどのように対処できますか?
プロジェクト:https://github.com/gpincheiraa/angularjs-tdd-jest/tree/dev
package.json
...
"scripts": {
"start": "npm run stubs & webpack-dev-server",
"dev": "npm start -- --open",
"stubs": "stubby -w -d stubs/fakeserver.yml -s 5000",
"tdd": "cross-env NODE_PATH=./src jest --watch --verbose",
"test": "cross-env NODE_PATH=./src jest --coverage --verbose",
"test:functional": "cucumberjs --require test/functional/ --compiler js:babel-register test/functional/",
//I want in the test:functional-ci task run the npm start and once that is serving the project, run npm run test:functional task
"test:functional-ci": "cross-env NODE_ENV=staging npm run test:functional",
"test-debug": "cross-env NODE_PATH=./src node --inspect --inspect-brk node_modules/.bin/jest -i",
"build": "webpack",
"check-coverage": "npm test | http-server -so -p 9000 coverage/lcov-report"
},
...
webpack.config.js
module.exports = {
entry: [
'core-js/shim',
'babel-polyfill',
'angular',
'./src/index.js'
],
output: {
path: 'dist',
filename: 'index.bundle.js'
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.(html)$/, loader: 'html-loader' },
{ test: /\.(woff|woff2)$/, loader:"url?prefix=font/&limit=5000" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" }]
},
cache: true,
devtool: 'eval-source-map',
devServer: {
filename: "index.bundle.js",
contentBase: "./src",
port: 3000,
watch: true,
publicPath: "/",
historyApiFallback: true,
stats: {
colors: true,
chunks: false
}
}
};
は、サーバーが稼働しているかどうかを確認しますキュウリのタスク内のロジックを追加することはできません(と繰り返しこれをチェック5回、1分間に1回)、サーバーが実際に稼働している場合にのみ続行しますか? – Adelin