Cypress의 Before, BeforeEach
Describe, Context, It
- Describe : 대상 선언(누가)
- Context : Case 언급(어떤 상황일 때)
- It : 결과 예상(어떻게 될 것이다)
describe('A함수는', () => {
context('b가 c일 때', () => {
it('x는 홀수값이다', () => {
//...
});
it('x는 3의 배수이다', () => {
//...
});
});
});
Before와 BeforeEach(After와 After Each)
코드
describe('describe1', () => {
before('before', () => console.log('describe1, before'));
beforeEach('beforeEach', () => console.log('describe1, beforeEach'));
context('context1', () => {
before('before', () => console.log('context1, before'));
beforeEach('beforeEach', () => console.log('context1, beforeEach'));
it('it1', () => console.log('it11'));
it('it2', () => console.log('it12'));
});
context('context2', () => {
before('before', () => console.log('context2, before'));
beforeEach('beforeEach', () => console.log('context2, beforeEach'));
it('it1', () => console.log('it21'));
it('it2', () => console.log('it22'));
});
});
describe('describe2', () => {
before('before', () => console.log('describe2, before'));
beforeEach('beforeEach', () => console.log('describe2, beforeEach'));
context('context21', () => {
before('before', () => console.log('context21, before'));
beforeEach('beforeEach', () => console.log('context21, beforeEach'));
it('it21', () => console.log('it21'));
});
});
결과
//before는 예상한 타이밍에 호출됨
describe1, before
context1, before
//beforeEach는 자기 하위 it 블럭이 실행될 때마다 순차적으로 반복
describe1, beforeEach
context1, beforeEach
it11
describe1, beforeEach
context1, beforeEach
it12
context2, before
describe1, beforeEach
context2, beforeEach
it21
describe1, beforeEach
context2, beforeEach
it22
describe2, before
context21, before
describe2, beforeEach
context21, beforeEach
it21
Author And Source
이 문제에 관하여(Cypress의 Before, BeforeEach), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@k2hyun4/Cypress의-Before-BeforeEach저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)