diff options
| author | ST-DDT <[email protected]> | 2023-03-19 12:57:45 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-19 12:57:45 +0100 |
| commit | 2fa095f7e51bf54a56106ae93473d70058a870e6 (patch) | |
| tree | c186d8ecfdbb14d72b210b49f4b7c4ebe2bcd334 | |
| parent | 1d4b4b8e8e6df5a7feb949ee6f5ed0b07d32d6ad (diff) | |
| download | faker-2fa095f7e51bf54a56106ae93473d70058a870e6.tar.xz faker-2fa095f7e51bf54a56106ae93473d70058a870e6.zip | |
infra: try to fix e2e flakyness (#1947)
| -rw-r--r-- | cypress/e2e/api.cy.ts | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts index a79c1957..e67ac213 100644 --- a/cypress/e2e/api.cy.ts +++ b/cypress/e2e/api.cy.ts @@ -23,20 +23,36 @@ describe('API Test', () => { it('should include at least 1 element in each module', () => { cy.get('.api-group').each(($el) => { - cy.wrap($el).get('li a[href]').should('have.length.above', 0); + cy.wrap($el).within(() => { + cy.get('li a[href]').should('have.length.above', 0); + }); }); }); it('should not have dead links', () => { + const checked = new Set<string>(); cy.get('.api-group li').each(($el) => { - const text = $el.find('a').text(); - const link = $el.find('a').attr('href'); + const anchor = $el.find('a'); + const text = anchor.text(); + const link = anchor.attr('href').split('#')[0]; + if (checked.has(link)) { + return; + } - cy.request(`/api/${link}`).should((response) => { - expect(response.status).to.eq(200); - expect(response.body).to.include(text); - expect(response.body).to.not.include('PAGE NOT FOUND'); - }); + checked.add(link); + + cy.request({ + method: 'HEAD', + url: `/api/${link}`, + failOnStatusCode: false, + }) + .should(({ status }) => { + expect( + status, + `${text} to have a working link: /api/${link}` + ).to.eq(200); + }) + .end(); }); }); }); |
