在 Docker Container 跑 Visual Testing 之基本設定
05 Apr 2022Cypress + Docker + Chromatic ❤️
步驟
- 下載 Docker。
- 建立 Dockerfile 來撰寫要跑的指令們,內容如下。
FROM cypress/base:16.13.0 # create cypress base image
RUN mkdir /app # create working directory for ducker build
WORKDIR /app # specify a path for a working directory
COPY . /app # copy cypress project code into the working directory
RUN npm install # install all dependencies
RUN $(npm bin)/cypress verify # verify cypress has been successfully installed and loaded, and make sure that cypress is ready
RUN ["npm", "run", "chromatic"] # run visual testing with chromatic
- 建立 docker ignore file (
.dockerignore
),忽略node_modules
,內容如下。
node_modules
- 開始在 docker container 跑測試!
docker build -t cypress . # create a docker image inside the root "." of the project.
- 跑完會收到結果。
- 在 Chromatic 查看結果。
更多細節。