I just try to clean up the code, so I decided to create a new function and import it in main.js. I create new a.js and move everything from "it ( () => {})" to this file and here starts my problem. Page.evaluate just don't work, I try to console.log, alert something but didn't work. So anyone could help me clean that mess?
PS When we put code from a.js to main.js everything is fine.
main.js:
const puppeteer = require('puppeteer');
const pti = require('puppeteer-to-istanbul');
const a= require('./a');
describe("test", async () => { (...)
it ('a.js', async ()=>{
await a(page);
a.js
const a = async (page) => {
const 1= '#1'
await page.waitForSelector(1, {visible: true})
await page.click(1)
await page.evaluate(async () => {
let value = "Z"
let clientPicker = document.querySelector('button[data-id="ctl00_CPH_Content__V_BPS_BankiProdukt__Q__Miejscowosc"]');
clientPicker.click();
let listOption = clientPicker.parentNode.querySelectorAll('li a > span')
Array.from(listOption).find(item => item.innerText == value).click()
}); (...)
}
module.exports = a;
SOLVED: I had to add /* istanbul ignore next */
await page.evaluate(/* istanbul ignore next */ () => {