Skip to content

Commit

Permalink
add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jun 8, 2023
1 parent 27bbd56 commit bbb16ba
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 41 deletions.
37 changes: 37 additions & 0 deletions cypress/e2e/inventory/inventory.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
describe('Inventory', () => {
interface Item {
name: string
desc: string
price: number
}

beforeEach(() => {
cy.log('**log in**')
cy.visit('/')
cy.getByTest('username').type('standard_user')
cy.getByTest('password').type('secret_sauce')
cy.getByTest('login-button').click()
cy.location('pathname').should('equal', '/inventory.html')
})

it('has every item from the inventory', () => {
// load the inventory JSON fixture file
// https://on.cypress.io/fixture
cy.fixture('inventory.json').then((items) => {
// iterate over every data item
items.forEach((item: Item) => {
cy.log(`checking 🎁 **${item.name}**`)
// and confirm there is an item on the page
// with the name, description, and price listed
// https://on.cypress.io/contains
// https://on.cypress.io/within
// Note: check the properties in the inventory object
cy.contains('.inventory_item', item.name).within(() => {
cy.contains('.inventory_item_name', item.name)
cy.contains('.inventory_item_desc', item.desc)
cy.contains('.inventory_item_price', item.price)
})
})
})
})
})
41 changes: 0 additions & 41 deletions cypress/e2e/login/verify-credentials.cy.ts

This file was deleted.

0 comments on commit bbb16ba

Please sign in to comment.