Created
December 25, 2017 09:46
-
-
Save conanak99/caed4306c1a9b1f04ca8768a3b9bf655 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
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