I finally got my first jest-puppeteer test to pass. - code below. However I am getting the warning shown.
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with --detectOpenHandles
to troubleshoot this issue.
I looked at other questions here on stackoverflow and it looked like I should be using 'done' which I added into my test. However I am still getting same warning. Test still passes.
Why am I getting warning?
/**
* @name Onplan Login
* @desc Logs in and test for correct page title
*/
const puppeteer = require('puppeteer');
const assert = require('assert');
let browser;
beforeAll(async () => {
browser = await puppeteer.launch({
headless: false,
devtools: false,
slowMo: 50
});
})
describe('url should be correct"', () => {
test('url is correct', async done => {
const page = await browser.newPage();
await page.goto('https://uat2.onplanapp.com/#/sheet/139');
await page.waitFor(500);//was 500
await page.waitFor('#inputEmail');
await page.type('#inputEmail', 'mayank@onplan.co');
await page.type('#inputPassword', '123456');
await page.click('button');//Login
await page.waitForNavigation();
await page.waitFor(100);//was 500
// SELECT COMPANY ON NEXT PAGE
await page.waitFor('#logn-screenv > form > div.row.logn-screenbody.pb-4.pt-3.px-2 > div:nth-child(2) > div > div > div.css-1hwfws3.custom-scrollbar__value-container > div.css-151xaom-placeholder.custom-scrollbar__placeholder');
await page.click('#logn-screenv > form > div.row.logn-screenbody.pb-4.pt-3.px-2 > div:nth-child(2) > div > div > div.css-1hwfws3.custom-scrollbar__value-container > div.css-151xaom-placeholder.custom-scrollbar__placeholder');//Login
// SELECT COMPANY
await page.waitFor(500);// was 1000
// click dropdown to show list of companies
await page.click('#react-select-2-option-2'); //Test company
await page.waitFor(300);//was 1000
await page.click('button[class="btn btn-block mt-3"]');
//now we go to first page
const url = await page.url();
expect(url).toBe('https://uat2.onplanapp.com/#/');
done();
}, 20000);
});