Created
June 19, 2021 09:00
-
-
Save hoangsetup/bc54f79b38d5a5e2a7be826ba7a7955d 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
import cartPo from './pages/cart.po'; | |
import inventoryPo from './pages/inventory.po'; | |
describe('Cart', () => { | |
beforeEach(async () => { | |
await inventoryPo.go(); | |
}); | |
it('should add correct products to cart', async () => { | |
const products = await inventoryPo.getProducts(); | |
const randomItems = products.sort(() => 0.5 - Math.random()).slice(0, 3); | |
for (const item of randomItems) { | |
await inventoryPo.addItemToCart(item.name); | |
} | |
expect(await inventoryPo.getCartCount()).toEqual(randomItems.length); | |
await cartPo.go(); | |
const cartItems = await cartPo.getCartItems(); | |
expect(cartItems.sort()).toEqual(randomItems.sort()); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment