Created
October 27, 2018 06:27
-
-
Save joeeames/64cb98c57a9c49ae19b175f715b21653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Home Page', () => { | |
beforeEach(() => { | |
}) | |
it('should have title', () => { | |
cy.seedAndVisit(); | |
cy.contains('Angular (2+)'); | |
}); | |
it('should have a default article', () => { | |
cy.seedAndVisit(); | |
cy.contains("Let's Get Started with Angular"); | |
}); | |
describe('search', () => { | |
beforeEach(() => { | |
}) | |
it('should search with real data', () => { | |
cy.server(); | |
cy.visit('/'); | |
cy.get('input.search').type('night'); | |
cy.get('.search-button').click(); | |
cy.get('app-article').should('have.length', 1); | |
}) | |
it('should filter to match when searching', () => { | |
cy.seedAndVisit(); | |
cy.get('input.search').type('forms'); | |
cy.get('.search-button').click(); | |
cy.get('app-article').should('have.length', 1); | |
}) | |
}) | |
describe('tags filtering', () => { | |
it('should only show the one returned search article when a tag is selected', () => { | |
cy.seedAndVisit(undefined, undefined, undefined, 'fixture:article2'); | |
cy.get('div.tags').eq(3).click(); | |
cy.get('app-article') | |
.should('have.length', 1) | |
.contains('Angular Forms FAQ'); | |
}) | |
it('should display all the related tags', () => { | |
cy.seedAndVisit(undefined, undefined, undefined, 'fixture:article2'); | |
cy.get('div.tags').eq(3).click(); | |
cy.get('div.tags').as('tags').should('have.length', 3); | |
cy.get('@tags').eq(0).contains('getting-started'); | |
cy.get('@tags').eq(1).contains('forms'); | |
cy.get('@tags').eq(2).contains('typescript'); | |
}) | |
it('should display the selected tag', () => { | |
cy.seedAndVisit(undefined, undefined, undefined, 'fixture:article2'); | |
cy.get('div.tags').eq(3).click(); | |
cy.get('div.tags a.bold') | |
.should('have.length', 1) | |
.contains('getting-started'); | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
beforeEach
blockcy.server()
to start Cypress proxy but never defines any routes to spy or stub, so it does it for nothingcy.seedAndVisit(undefined, undefined, undefined, 'fixture:article2')
?cy.get('div.tags')
but they less than perfect I think. Our guide in https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements goes into details