Prior99 / jest-screenshot

A jest extension to deal with screenshots and all sorts of images.
MIT License
71 stars 21 forks source link

Possibility to send options when configuring jest framework #5

Closed fernandopasik closed 5 years ago

fernandopasik commented 6 years ago

Hi

Would it be possible to setup options when doing the jest framework setup?

import { setupJestScreenshot } from "jest-screenshot";

setupJestScreenshot({
 // options here
});

I find it a bit better than having to add a json file in the root folder just for configuring this library. Usually all jest related config goes into a setupTestFrameworkScriptFile.

The key in package.json doesn't seem like a good option either as it would pollute the file.

Thanks!

Prior99 commented 6 years ago

Sadly, this is not possible due to the way jest works. Jest-screenshot runs in as well the processes executing the tests as a reporter writing the report after all tests have finished. The code you proposed would only be executed in the processes executing the tests but not for the reporter. Hence an external configuration file is needed.

I actually also would have preferred to specify the configuration when calling setupJestScrenshot.

If you ever find a way to implement this, please let me know, I'd love to integrate it.

tujoworker commented 5 years ago

ahh, so this would not work? https://github.com/Prior99/jest-screenshot/pull/12

Prior99 commented 5 years ago

I will try to have a look at it on the weekend. Thanks.

tujoworker commented 5 years ago

Nice @Prior99 A quick test locally shows that it works fine to pass along a config in the setup. At least with jest v24. Would ♥️ to hear form You about the #12 in a couple of days.

Prior99 commented 5 years ago

I guess this can be closed now with #12 merged and published? Sorry for the delay by the way.

fernandopasik commented 5 years ago

Yes! this looks good, thanks!