What could be the reason of me not being able to access the Proxy of the CustomPage
class in my test file? I get this error...
enter image description here
const puppeteer = require("puppeteer");
class CustomPage {
static async build() {
const browser = await puppeteer.launch({
headless: false,
});
const page = await browser.newPage();
const customPage = new CustomPage(page);
return new Proxy(customPage, {
get: function (target, property) {
return customPage[property] || browser[property] || page[property];
},
});
}
constructor(page) {
this.page = page;
}
getContentsOf(selector) {
return this.page.$eval(selector,el=>el.innerHTML);
}
}
module.exports = CustomPage;
const Page = require("./helpers/page");
let page;
beforeEach( async () => {
page = await Page.build();
await page.goto('http://localhost:5002');
});
afterEach(async () => {
await page.close();
});
describe("we started HomePage tests and...",() => {
test("can see blog create form", async () => {
const subscribeButton = await page.$eval(".subscribe-btn",el=>el.innerHTML);
expect(subscribeButton).toEqual("გამოწერა");
});
});
I don't know what exactly should I try to fix it.