How to switch test environment in Heroku
I am writing a code to Heroku for exclusively these days.I use the foreman when debugging in the local environment, but it is inconvenient if do not switch the test environment.
foreman is be able to select Procfile and .env at startup.
Create testProcfile like that.
test: npm test
Create .env like that.
TEST_VAL=TEST
Then
foreman start --env .testenv --procfile testProcfile
And I started with a set of these. It is a good idea to go out where reasonable values in test environment and debugging environment. (For example, such as the destination of DB)
最近はもっぱら Heroku 向けにコードを書いています。ローカル環境でデバッグするときには foreman を使うのですが、テスト環境を切り替えられないと不便です。
調べてみると、 foreman は起動時に Procfile と .env を選択できるようです。
test: npm test
のような testProcfile を作成し、
TEST_VAL=TEST
のような .testenv を用意します。そして、
foreman start --env .testenv --procfile testProcfile
とすると、これらの設定で起動してくれます。デバッグ環境とテスト環境で値が変わる部分は外出ししておくと便利です。(たとえばDBの接続先とか)
Written by jigsaw
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Heroku
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#