Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.