File size: 1,104 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
describe('form setError', () => {
  it('should contain 3 errors when page land', () => {
    cy.visit('http://localhost:3000/setError');

    cy.get('#error0').contains('0 wrong');
    cy.get('#error1').contains('1 wrong');
    cy.get('#error2').contains('2 wrong');
    cy.get('#error3').contains('3 test');
    cy.get('#error4').contains('4 required');
    cy.get('#error5').contains('5 minLength');
    cy.get('#error').contains(
      'testMessageThis is required.Minlength is 10This is requiredThis is minLength',
    );
  });

  it('should clear individual error', () => {
    cy.visit('http://localhost:3000/setError');

    cy.get('#clear1').click();
    cy.get('#clear2').click();
    cy.get('#error0').contains('0 wrong');
  });

  it('should clear an array of errors', () => {
    cy.visit('http://localhost:3000/setError');

    cy.get('#clearArray').click();
    cy.get('#error0').contains('0 wrong');
  });

  it('should clear every errors', () => {
    cy.visit('http://localhost:3000/setError');

    cy.get('#clear').click();
    cy.get('#errorContainer').should('not.value');
  });
});