testimio / root-cause

🔍 [DEPRECATED] Root Cause is a tool for troubleshooting Puppeteer and Playwright tests. 🔎
GNU Affero General Public License v3.0
265 stars 16 forks source link

Using root-cause jest integration with typescript (ts-jest) #24

Open talkl opened 3 years ago

talkl commented 3 years ago

Hi, i'm trying to use Root Cause Jest integration and see the results locally, but because i'm using a page of puppeteer-cluster i suspect the results are not logged to root cause, when i tried to use the page, as shown in the jest example, it couldn't understand where page variable is defined (I'm using typescript). So when i open npx root-cause show i see nothing.

Thank you guys

benjamingr commented 3 years ago

Hey, interesting.

Any chance you can make a repro repository?

So when i open npx root-cause show i see nothing.

When you say nothing, do you mean "no runs found" or "a run with no screenshots"?

it couldn't understand where page variable is defined (I'm using typescript).

Root cause (automatic integration) expects a page global variable (globalThis.page) like jest-puppeteer defines. You can use root-cause without jest-puppeteer or defining a global using the lower-level .attach API.

I suspect that https://github.com/thomasdondorf/puppeteer-cluster would require you to (instead of using the setupFilesAfterEnv jest hook) use rootCause.attach directly on the pages inside cluster.task

benjamingr commented 3 years ago

@Bnaya any chance we can add a (small) example of puppeteer-cluster to our examples?

Bnaya commented 3 years ago

Seems that puppeteer-cluster is mostly for scraping, would need to hear more about @talkl use case

talkl commented 3 years ago

@bnaya @benjamingr ok i decided to go with the page that is attached with the jest puppeteer integration since i guess i will avoid bugs that can happen from not using the recommended way of getting a page. i would just add in the documentation this line const page = (global as any).page; or else typescript yells that it doesn't understand where is page defined.

benjamingr commented 3 years ago

We use TypeScript throughout this project - you can see integration examples in https://github.com/testimio/root-cause/tree/main/integration-examples - I'll hit you up (on FB)

Bnaya commented 3 years ago

Hey @talkl, I'm closing this issue, if the problem persists please open new one Thanks!