I'm trying to test my component using mocha and google puppeteer. In my unit test file i'am launching puppeteer browser in before and closing the browser in after function. When i'm running my test file i'm getting following error in "Before All" hook Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
const puppeteer = require('puppeteer');
const { expect } = require('chai');
const _ = require('lodash');
/* create the global variable by using lodash function */
const globalVariables = _.pick(global, ['browser', 'expect']);
/* configurable options or object for puppeteer */
const opts = {
headless: false,
slowMo: 100,
timeout: 0,
args: ['--start-maximized', '--window-size=1920,1040']
}
/* call the before for puppeteer for execute this code before start testing */
before (async () => {
global.expect = expect;
global.browser = await puppeteer.launch(opts);
});
/* call the function after puppeteer done testing */
after ( () => {
browser.close();
global.browser = globalVariables.browser;
global.expect = globalVariables.expect;
});