You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible for this library to support the --noStackTraceJest flag out of the box? That is, all console.x should still cause an error, and print expected not to call... but have no stack trace? It looks like this might be possible with a custom error message, but it might make sense for it to work automatically. I also might like to always have no stack traces for fail on console, but that's a stretch goal. I could also consider a PR if you could point me in the right direction.
If it should work and I have something wrong, let me post my exact behavior. Jest is run as a script through pnpm, so my actual command and output looks like this: pnpm jest -- TheTestToRun
TheTestToRun
Expected test not to call console.warn().
If the warn is expected, test for it explicitly by mocking it out using jest.spyOn(console, 'warn') and test that the warning occurs.
Unmatched GET to /logout/expire_if_idle
at console.newMethod (/Users/.../node_modules/.pnpm/jest-fail-on-console@2.1.1/node_modules/jest-fail-on-console/index.js:20:25)
... continues for ~20 more lines
When using pnpm jest -- --silent --noStackTrace TheTestToRun, I get the exact same output.
The text was updated successfully, but these errors were encountered:
The important thing for this to work automatically is to know if there is a way to detect that this flag was passed. I couldn't find any info about this topic.
Thanks for the quick response! I see that it's not nearly as much code as I was picturing, I'll see if I can get a pull request together, maybe later in the month. I'll also see if I can find out if Jest makes the flag status available anywhere.
Pazns
pushed a commit
to Pazns/jest-fail-on-console
that referenced
this issue
Jan 28, 2023
Is it possible for this library to support the
--noStackTrace
Jest flag out of the box? That is, allconsole.x
should still cause an error, and printexpected not to call...
but have no stack trace? It looks like this might be possible with a custom error message, but it might make sense for it to work automatically. I also might like to always have no stack traces for fail on console, but that's a stretch goal. I could also consider a PR if you could point me in the right direction.If it should work and I have something wrong, let me post my exact behavior. Jest is run as a script through pnpm, so my actual command and output looks like this:
pnpm jest -- TheTestToRun
When using
pnpm jest -- --silent --noStackTrace TheTestToRun
, I get the exact same output.The text was updated successfully, but these errors were encountered: