Created
March 28, 2018 03:58
-
-
Save evantahler/19adb958dc5987c1723ca26564589041 to your computer and use it in GitHub Desktop.
Testing Node.JS browser apps with Selenium, Async/Await, and Jest
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
/** | |
* @jest-environment jest-environment-webdriver | |
*/ | |
const url = 'https://www.actionherojs.com' | |
describe('www.actionherojs.com#index', () => { | |
test('it renders', async () => { | |
await browser.get(url) | |
const title = await browser.findElement(by.tagName('h2')).getText() | |
expect(title).toContain('reusable, scalable, and quick') | |
}) | |
test('loads the latest version number from GitHub', async () => { | |
const foundAndLoadedCheck = async () => { | |
await until.elementLocated(by.id('latestRelease')) | |
const value = await browser.findElement(by.id('latestRelease')).getText() | |
return value !== '~' | |
} | |
await browser.wait(foundAndLoadedCheck, 3000) | |
const latestRelease = await browser.findElement(by.id('latestRelease')).getText() | |
expect(latestRelease).toEqual('v18.1.3') | |
}) | |
describe('save a screenshot from the browser', () => { | |
test('save a picture', async () => { | |
// files saved in ./reports/screenshots by default | |
await browser.get(url) | |
await browser.takeScreenshot() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment