Skip to content

Instantly share code, notes, and snippets.

@kevinguebert
Created August 6, 2018 22:45
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 kevinguebert/7a5d487f501e9b4fc687e38a0480fe5d to your computer and use it in GitHub Desktop.
Save kevinguebert/7a5d487f501e9b4fc687e38a0480fe5d to your computer and use it in GitHub Desktop.
Testing with Puppeteer - Part 2
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 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")
});
});
{
"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