课程: End-to-End JavaScript Testing with Cypress.io

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Working with test doubles

Working with test doubles

- [Instructor] All right, so the next thing that we're going to talk about here is working with something called test doubles in Cypress. As a general rule, when we're end-to-end testing, as we almost always are with Cypress, we want the app that we're testing to mimic the production environment as closely as possible. This means that we want to be very careful about using techniques that are popular in unit and integration testing, such as mocking, or stubbing, or other test doubles. These are meant in unit and integration testing to make it easier to test individual pieces of our app in isolation. So, usually, using test doubles in end-to-end testing is going to kind of ruin the point of end-to-end testing in the first place. Now, that being said, there are times when using test doubles is the best option, even in end-to-end testing. For example, if we need to see how our app works when it encounters a server error, it's usually much easier to simply create a server stub that…

内容