mocha icon indicating copy to clipboard operation
mocha copied to clipboard

Running tests in browser and have reports in CLI

Open hosseinalipour opened this issue 3 years ago • 1 comments

I want to utilize devtool protocol to have tests executed in a real browser environment and have the reports back to CLI or for that matter, I want to use it as API. so, I thought it would be easy to use mocha API for browsers and have it injected into the browser and get back the reports to the CLI where it was first initiated.

I could have used JSDOM but e.g. it doesn't support layout engine. also, the problem I have is that I need to target specific browser vendors with specific versions

This is mostly a nice-to-have feature and not required for most cases, but, I strictly need to run some tests in a REAL browser environment. the reason I opened the issue is to avoid forking as it's my last resort. another reason I want to do this it will greatly enhance my development process and I'm lazy!

The first problem I had to implement this is that I saw mocha shim process and checked for the terminal to be TTY. when this happens the colors are disabled and I get a color-less report in my CLI. I need some guidance regarding how I can use the current mocha API to fix this, or if there is a chance that I can create a pull request. the exact requirement I have is I need to override useColors

hosseinalipour avatar Aug 05 '22 20:08 hosseinalipour

I've had some luck combining esbuild + playwright to bundle the tests and run them in an browser with logs printed back to the terminal

dmaretskyi avatar Aug 10 '22 20:08 dmaretskyi

This is a pretty big feature request (albeit a pretty cool & useful sounding one). Out of scope for Mocha core, but you can always write it yourself with Mocha's API. Good luck!

JoshuaKGoldberg avatar Dec 27 '23 06:12 JoshuaKGoldberg