Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created December 25, 2017 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conanak99/caed4306c1a9b1f04ca8768a3b9bf655 to your computer and use it in GitHub Desktop.
Save conanak99/caed4306c1a9b1f04ca8768a3b9bf655 to your computer and use it in GitHub Desktop.
let puppeteer = require('puppeteer');
let browser = null;
let page = null;
describe('Lazada test', () => {
// Code này được chạy khi bắt đầu chạy unit test
beforeAll(async() => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.setViewport({
width: 1280,
height: 720
});
// Mặc định, timeout của jest là 5s.
// Vì web load có thể lâu nên ta tăng lên thành 60s.
jest.setTimeout(60000);
});
// Đóng trình duyệt sau khi đã chạy xong các test case
afterAll(async() => {
await browser.close();
});
// Trước khi chạy mỗi test case, vào trang chủ của lazada
beforeEach(async() => {
await page.goto('https://lazada.vn');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment