我已经创建了一个运行我的角度项目的docker容器,现在我试图在容器内运行我的单元测试失败。我需要一个无头浏览器来运行我的测试,而PhantomJS对我的口味来说太麻烦了,在运行测试时也会给Chrome带来不同的结果。如何在Docker容器中运行单元测试
在这里,我提供我的Dockerfile:
# download (or use if it's in cache) the latest official image from node
FROM node:latest
# create directory in the container and set all privileges
RUN mkdir -p /usr/src/app && chmod 777 /usr/src/app
# make the directory available for following commands
WORKDIR /usr/src/app
# copy all local's frontend content to the WORKDIR
COPY . /usr/src/app
# Expose the port the app runs in
EXPOSE 4200
CMD ["npm", "start"]
我用无头Chrome尝试,但仍需要更多的配置,我不知道该怎么做。任何人有任何想法?
几个月前我遇到了无头浏览器的问题,一些测试失败了,因为它无法将浏览器滚动到我试图查看它们是否存在的元素。如果你有一些失败的测试,记住这一点。 无论如何,你为什么要运行ng服务而不是ng测试? –
,因为我将在稍后的时刻运行'test'命令 –
您是否在使用Selenium webdriver for NodeJS或者您正在使用protactor? –