공부/Vue.js
[Vue.js] E2E 테스트 - Cypress API
도리암
2022. 4. 23. 10:54
참조) Table of Contents | Cypress Documentation
Table of Contents | Cypress Documentation
Cypress API Documentation Table of Contents
docs.cypress.io
Cypress에서 제공하는 API에 대한 웹사이트이다.
Should
단위 테스트의 toBe, toEqual과 유사한 용도로 사용된다.
should를 사용하려면 assertions 개념을 알아야된다고 강조 돼 있다.
쉽게 말하면, 테스트할 때 기대하는 대로 흘러갈 수 있도록 자동적으로 테스트를 조정하는 기능이라고 한다.
만약, <button> 요소를 클릭하면 active라는 클래스가 생기는 것을 테스트한다고 하면
비동기로 active가 생성되거나, 일정 시간 이후에 생기더라도 그것을 감지한다는 의미다.
참고) Assertions | Cypress Documentation
Assertions | Cypress Documentation
Cypress bundles the popular Chai assertion library, as well as helpful extensions for Sinon and jQuery, bringing you dozens of powerful assertions for
docs.cypress.io
모든 Assertion의 문법을 확인할 수 있다.