How to setup unit test in Docker for nodejs application?

痞子三分冷 提交于 2019-12-05 18:03:22
jdno

With docker (and docker-compose), you can run arbitrary commands in a container. The Dockerfile defines the default command that is run when no other command is specified, but that doesn't mean it's the only one you can run.

In your case: npm start is run when no other command is specified. That happens when you do docker-compose up.

But, you can run any command using docker run or docker-compose run. For your tests, that might look like this: docker-compose run web mocha.

There is a slight difference in up and run, and I encourage you to read up on it: Should I use docker-compose start up or run?

Does this help you get started?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!