diff options
| author | Shinigami <[email protected]> | 2022-09-09 20:07:17 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-09-09 20:07:17 +0800 |
| commit | 0c6e9b16548614dc0ce91296e3885c9e421e4e99 (patch) | |
| tree | 49aa500525d26a8ac962fca4a7b026395cf694be /cypress | |
| parent | 83b61429fa710903e4a82fe655a6c196deb16fbd (diff) | |
| download | faker-0c6e9b16548614dc0ce91296e3885c9e421e4e99.tar.xz faker-0c6e9b16548614dc0ce91296e3885c9e421e4e99.zip | |
test: e2e tests (#1362)
Diffstat (limited to 'cypress')
| -rw-r--r-- | cypress/e2e/api.cy.ts | 43 | ||||
| -rw-r--r-- | cypress/e2e/guide.cy.ts | 13 | ||||
| -rw-r--r-- | cypress/e2e/smoke.cy.ts | 26 | ||||
| -rw-r--r-- | cypress/tsconfig.json | 7 |
4 files changed, 61 insertions, 28 deletions
diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts new file mode 100644 index 00000000..ec21d3d3 --- /dev/null +++ b/cypress/e2e/api.cy.ts @@ -0,0 +1,43 @@ +describe('API Test', () => { + it('navigates to the api index search', () => { + // given + cy.visit('/'); + + // when + cy.get('a').contains('API').click(); + + // then + cy.url().should('include', '/api/'); + cy.contains('API Reference'); + }); + + describe('API Reference', () => { + beforeEach(() => { + // given + cy.visit('/api/'); + }); + + it('should at least list more than 7 modules', () => { + cy.get('.api-group').should('have.length.above', 7); + }); + + 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); + }); + }); + + it('should not have dead links', () => { + cy.get('.api-group li').each(($el) => { + const text = $el.find('a').text(); + const link = $el.find('a').attr('href'); + + cy.visit(`/api/${link}`); + + cy.get('h2').should('include.text', text); + cy.get('h1').should('not.include.text', 'PAGE NOT FOUND'); + cy.go('back'); + }); + }); + }); +}); diff --git a/cypress/e2e/guide.cy.ts b/cypress/e2e/guide.cy.ts new file mode 100644 index 00000000..6186f938 --- /dev/null +++ b/cypress/e2e/guide.cy.ts @@ -0,0 +1,13 @@ +describe('Guide Test', () => { + it('navigates to the getting started section', () => { + // given + cy.visit('/'); + + // when + cy.get('a').contains('Get Started').click(); + + // then + cy.url().should('include', '/guide/'); + cy.contains('Getting Started'); + }); +}); diff --git a/cypress/e2e/smoke.cy.ts b/cypress/e2e/smoke.cy.ts deleted file mode 100644 index eb3cf1fb..00000000 --- a/cypress/e2e/smoke.cy.ts +++ /dev/null @@ -1,26 +0,0 @@ -describe('Smoke Test', () => { - beforeEach(() => { - cy.visit('/guide/'); - cy.get('a[href="/api/animal.html"]').as('firstSectionLink'); - }); - - it('compiles the guide page', () => { - cy.contains('Getting Started'); - }); - - it('renders this last code example in the code', () => { - // Click on any section in the sidebar - cy.get('@firstSectionLink') - .click() - // Make sure the number of code examples is the same between reloads - .get('.container pre code') - .then(($codeBlocks) => { - // Trigger a reload - cy.reload() - // Give the runtime a chance to update/fail - .wait(500) - .get('.container pre code') - .should('have.length', $codeBlocks.length); - }); - }); -}); diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index 5e8cb532..0446ab75 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,8 +1,11 @@ { "compilerOptions": { "target": "ES5", - "lib": ["ES5", "DOM"], - "types": ["cypress"] + "lib": ["ES2015", "DOM"], + "types": ["cypress"], + "esModuleInterop": true, + "noEmit": true, + "resolveJsonModule": true }, "include": ["**/*.ts"] } |
