Pytorch-NLU icon indicating copy to clipboard operation
Pytorch-NLU copied to clipboard

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

Open talkl opened this issue 5 years ago • 6 comments

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

talkl avatar Sep 21 '20 08:09 talkl

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 avatar Sep 21 '20 08:09 benjamingr

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

benjamingr avatar Sep 21 '20 08:09 benjamingr

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

Bnaya avatar Sep 21 '20 12:09 Bnaya

@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.

talkl avatar Sep 21 '20 12:09 talkl

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)

benjamingr avatar Sep 21 '20 13:09 benjamingr

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

Bnaya avatar Oct 27 '20 12:10 Bnaya