Open AaronWatson2975 opened 1 year ago
I'm looking through the code and think it would be easy to implement. This as currently the console-log-output is already being captured, to be displayed on an actual Storybook-story-error.
It looks like there's now a --failOnConsole
option. Should this be closed?
I think this issue might be closed. The "failOnConsole" option seems to work. Although it only works with Angular with Storybook when build NOT in production-mode. In NX this is controlled with the option enableProdMode=false.
Description
I'm wondering if there is a way to fail tests when errors or warnings are written to the console. There are a number of scenarios where I believe this could be a huge benefit (for example, with React UI libraries, prop type validation could be a great thing to catch in these tests).
Things I've Tried
jest-fail-on-console
, and hooked it up viasetupFilesAfterEnv
in the Jest configerror
orwarning
are called viasetupFilesAfterEnv
Neither seemed to work (I was able to confirm the code was running, but the tests were still passing), despite working as expected with a vanilla Jest implementation.
Example
Here is an example of how I attempted to implement
jest-fail-on-console
test-runner-jest-config.js
test/setupStorybookTests.js
Additional context
I just wanted to say thanks for creating this wonderful library, out of the box, being able to check all your stories to ensure they render without throwing errors with almost no setup, is a huge benefit. IMO having a way to fail on console errors and warnings could make it an even better value prop.