Last active
May 12, 2019 14:19
-
-
Save M4R14/cb5aa4a386a5653bbf0dd588583115f8 to your computer and use it in GitHub Desktop.
วิธีใส่ Puppeteer เข้าไปใน Jest เพื่อทำ UI Testing ในโหมด headless browser อย่างง่าย… / sol.A - http://vachirawit.com/puppeteer-and-jest-testing-headless-browser/
This file contains hidden or 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
| const puppeteer = require('puppeteer'); | |
| const Chrome = async ({ STEP }) => { | |
| const browser = await puppeteer.launch({ headless: false }); | |
| const page = await browser.newPage(); | |
| await STEP(browser, page); | |
| browser.close(); | |
| } | |
| test('Title == Google', async () => { | |
| await Chrome({ | |
| STEP: async (browser, page)=>{ | |
| page.goto("https://google.com"); | |
| const title = await page.title(); | |
| expect(title).toBe("Google"); | |
| } | |
| }); | |
| }, 1000*30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment