Cypress UI/API测试的使用参考

官网的深入示例

https://docs.cypress.io/examples/examples/recipes.html

 

类别

地址和备注

workshop

https://docs.cypress.io/examples/examples/workshop.html#End-to-end-Testing-with-Cypress-io

 

https://github.com/cypress-io/testing-workshop-cypress 这里有初中高级别的学习说明。包含一步步如何把工程等做出来的

Recipes

https://docs.cypress.io/examples/examples/recipes.html#Fundamentals

各种技术点的菜单式讲解

视频

https://docs.cypress.io/examples/examples/tutorials.html

需要FQ

Applications

https://docs.cypress.io/examples/examples/applications.html

完整的应用工程测试的例子

Kitchen Sink Vanilla Showcases every single Cypress command 展示每个命令的用法

TodoMVC React Compares the official TodoMVC Selenium tests to Cypress TodoMVC和selenium的对比

Realworld React Full end-to-end tests for the gothinkster/realworld “Conduit” app 完整的应用工程测试

 

 

 

相关资料内网confluence搜索关键词 cypress

 

Docker方式运行环境

除了普通的安装方式外,这里对基于docker的运行方式进行一个总结。

docker方式比较简单,依赖少,多人工作时比较方便

运行模式

https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command/

Running headless tests-后台运行模式

If you have Cypress end-to-end tests, you can run them using the complete image. For example, if your project structure looks like this:

cypress/

  integration/

    spec.js

cypress.json

Then you can execute your Cypress tests using the following shell command:

$ docker run -it -v $PWD:/e2e -w /e2e cypress/included:3.2.0

Interactive mode-交互模式

DISPLAY=$IP:0

docker run -it \

  -v $PWD:/e2e \

  -v /tmp/.X11-unix:/tmp/.X11-unix \

  -w /e2e \

  -e DISPLAY \

  --entrypoint cypress \

  cypress/included:3.2.0 open --project .

镜像类别

https://docs.cypress.io/examples/examples/docker.html

cypress/base:<Node version> has the operating system dependencies required to run Cypress.

Cypress依赖的运行环境

cypress/browsers:<tag> extends the base images with pre-installed browsers.

包含了浏览器的镜像Docker image with all operating system dependencies and some pre-installed browsers, but NOT Cypress itself. See cypress/included images if you need Cypress pre-installed in the image.

 

下载地址

https://hub.docker.com/r/cypress/browsers/tags

cypress/included:<Cypress version> extends the base images with pre-installed Cypress versions.

安装好的可用的cypress镜像【有内置浏览器的版本】Docker images with all operating system dependencies, Cypress, and some pre-installed browsers.

 

下载地址

https://hub.docker.com/r/cypress/included/tags

镜像的完整类别地址

https://github.com/cypress-io/cypress-docker-images

 

 

cypress/included:6.1.0

cypress/browsers:node12.18.3-chrome87-ff82

914M

 

完整的使用说明

https://github.com/cypress-io/cypress-docker-images/tree/master/included

 

docker run -it -v $PWD:/e2e -w /e2e cypress/included:6.1.0

示范例子

基础:由有于需要在容器中运行GUI程序vscode和cypress runner,因此宿主机器需要有X11 Server服务,不同的系统的情况

l Linux: 只要安装了Linux桌面默认就可用

l Windows:参考Linux服务器的x11方式远程管理参考”

由于需要写脚本等,不建议使用windows,统一使用linux桌面版【centos7安装时选择桌面即可】

 

示范目录说明

  • 1 dev

n 基于官方的发布镜像做一个完整的包含开发工具vscode的再发布镜像

n ide.sh 执行这个即可生成,详细参考其中的说明

  • 2.1 starter

n 最简单的一个测试工程

n run.sh 执行这个可以直接启动vscode 和cypress runner

 

  • 2.2 conduit-app cypress-realworld-app-develop

n 这是官方发布的2个完整的WEB系统测试

n run.sh 执行这个可以直接启动vscode 和cypress runner

【例子和文档在 https://gitee.com/wushifeng/cypressKit 这里可以查看】

整体的运行效果类似如下图

 

posted @ 2021-03-16 08:43  2012  阅读(443)  评论(0编辑  收藏  举报