Created
August 6, 2018 22:45
-
-
Save kevinguebert/7a5d487f501e9b4fc687e38a0480fe5d to your computer and use it in GitHub Desktop.
Testing with Puppeteer - Part 2
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
const puppeteer = require('puppeteer'); | |
const { expect } = require('chai'); | |
const _ = require('lodash'); | |
before (async function () { | |
global.expect = expect; | |
global.browser = await puppeteer.launch({headless: true}); | |
}); | |
after (function () { | |
browser.close(); | |
}); |
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
// This file should be inside the "test" folder. | |
// test/homepage.spec.js | |
describe('Homepage Test', function() { | |
before (async () => { | |
page = await browser.newPage(); | |
await page.goto('http://www.outsideonline.com', { waitUntil: 'networkidle2' }); | |
}); | |
it("should have the title", async () => { | |
expect(await page.title()).to.eql("Outside Online") | |
}); | |
}); |
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
{ | |
"name": "000-puppeteer-tutorial", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "mocha bootstrap.js --recursive test/ --timeout 30000" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"chai": "^4.1.2", | |
"mocha": "^5.2.0" | |
}, | |
"dependencies": { | |
"lodash": "^4.17.10", | |
"puppeteer": "^1.5.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment