[Cypress] Create True end-to-end Tests with Cypress (Smoke test)
Integration tests let us keep our tests fast and reliable. They also allow us to test scenarios that are hard to recreate in a full end-to-end setup. That being said, we should round out our test suite with some high-level smoke tests. In this lesson, we’ll create some tests that seed our data-source and avoid stubbing our network calls, allowing us to test all parts of the application while using known data to keep our tests flake-free.
describe('Smoke Tests', () => { // context is no difference with describe in functionality
context('No Todos', () => {
it('Adds a new todo', () => {
cy.server()
cy.route('POST', '/api/todos').as('save') cy.visit('/') cy
.get('.new-todo')
.type('New todo')
.type('{enter}') cy.wait('@save') cy.get('.todo-list li').should('have.length', ) })
}) });
Now we have post a new todo to the backend, it will pass the test.
But the problem is that, when you rerun the test again, it will faild, because now in the db, we have two todos.
Therefore, we need to clear the db everytime before we run the test:
describe('Smoke Tests', () => {
beforeEach(() => {
cy.request('DELETE', '/api/todos/all')
}) // context is no difference with describe in functionality
context('No Todos', () => {
it('Adds a new todo', () => {
cy.server()
cy.route('POST', '/api/todos').as('save') cy.visit('/') cy
.get('.new-todo')
.type('New todo')
.type('{enter}') cy.wait('@save') cy.get('.todo-list li').should('have.length', 1) })
})
})
Another example:
context('With todos', () => {
beforeEach(() => {
cy.fixture('todos').then(todos => {
cy.request('POST', '/api/todos/bulkload', {todos})
}) cy.server()
cy.route('GET', '/api/todos').as('load') cy.visit('/') cy.wait('@load')
}) it('Deletes todos', () => {
cy.route('DELETE', '/api/todos/*').as('delete') cy
.get('.todo-list li')
.each($el => {
cy
.wrap($el)
.find('.destroy')
.invoke('show')
.click() cy.wait('@delete')
})
.should('not.exist')
})
})
About smoke test
[Cypress] Create True end-to-end Tests with Cypress (Smoke test)的更多相关文章
- Cypress系列(1)- Window下安装 Cypress 并打开
如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 系统要求 Cypress 是一个被安装在 ...
- [Cypress] Create Aliases for DOM Elements in Cypress Tests
We’ll often need to access the same DOM elements multiple times in one test. Your first instinct mig ...
- [Cypress] Create a Single Custom Cypress Command from Multiple Commands
Cypress provides a straightforward API that allows you to define custom commands. In this lesson, we ...
- Cypress系列(44)- 命令行运行 Cypress
如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 前面也介绍过 Cypress 命令 ...
- [Cypress] install, configure, and script Cypress for JavaScript web applications -- part1
Despite the fact that Cypress is an application that runs natively on your machine, you can install ...
- Cypress测试工具
参考博客: https://testerhome.com/articles/19035 最近一段时间学习了cypress的测试工具, 她是一个端到端的测试web工具. 环境准备 1.工具:vs co ...
- [Cypress] install, configure, and script Cypress for JavaScript web applications -- part3
Use custom Cypress command for reusable assertions We’re duplicating quite a few commands between th ...
- [Cypress] install, configure, and script Cypress for JavaScript web applications -- part2
Use Cypress to test user registration Let’s write a test to fill out our registration form. Because ...
- [Cypress] Get started with Cypress
Adding Cypress to a project is a simple npm install away. We won’t need any global dependencies beyo ...
随机推荐
- python抢票开发——设备预约助手实现
女朋友是药学院的,做实验时需要在特定的网站上进行设备预约,由于预约人数过多,从而导致从浏览器登录不进去或者登录进去预约失败等情况,所以我用python帮她写了一个抢位助手,让程序自动去进行位置预定,实 ...
- 去掉myeclipse的预览窗口
1,选择菜单: windows -> preferences2,在弹出窗口中选择General-> Editors -> FileAssociations3,在上方框内选择*.jsp ...
- Squirrel的安装(windows上Phoneix可视化工具)
一.下载安装 下载地址:http://www.squirrelsql.org/下载所需版本 或者 从网址http://www.squirrelsql.org/下载相应版本的squirrel ...
- reactnative(1) - RefreshControl 使用案例
'use strict'; import React, { Component } from 'react'; import { AppRegistry, ScrollView, StyleSheet ...
- 3--Java NIO基础1
一.NIO概述 1. BIO带来的挑战 BIO即堵塞式I/O,数据在写入或读取时都有可能堵塞,一旦有堵塞,线程将失去CPU的使用权,性能较差. 2. NIO工作机制 Java NIO由Channel. ...
- jQuery怎么去掉标签的hover效果
今天项目中遇到jquery去掉hover效果的问题,开始以为直接unbind(“hover”)就可以搞定,可是实际验证这个方法并没有作用,正确的使用方法应该是下面这样: /* 这种方法是新增的,在老的 ...
- 轻松理解 Android Binder,只需要读这一篇
在 Android 系统中,Binder 起着非常重要的作用,它是整个系统 IPC 的基石.网上已经有很多文章讲述 Binder 的原理,有的讲的比较浅显,没有触及到关键,有的讲的太过于深入底层,难以 ...
- 为什么有些异常throw出去需要在函数头用throws声明,一些就不用
throw new IllegalStateException(".");不用在函数头声明throws IllegalStateExceptionthrow new IOExcep ...
- Apache 在Linux上的安装
1.获取源码 wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.37.tar.gz 2.卸载centos自带的apache 3.解压apach ...
- 查询数据表行数 然后循环查找表 添加数据到ITEMS
;i<tbBiao.Rows.Count;i++) { string TableName = (tbBiao.Rows[i]["Table"]).ToString(); tb ...