Skip to content

Instantly share code, notes, and snippets.

@hoangsetup
Created June 19, 2021 09:00
Show Gist options
  • Save hoangsetup/bc54f79b38d5a5e2a7be826ba7a7955d to your computer and use it in GitHub Desktop.
Save hoangsetup/bc54f79b38d5a5e2a7be826ba7a7955d to your computer and use it in GitHub Desktop.
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