Skip to content

Instantly share code, notes, and snippets.

@Yiannistaos
Last active February 21, 2024 14:43
Show Gist options
  • Save Yiannistaos/aa15cbe38eda78a583f63bd2238c470f to your computer and use it in GitHub Desktop.
Save Yiannistaos/aa15cbe38eda78a583f63bd2238c470f to your computer and use it in GitHub Desktop.
This gist includes commands for saving yarn test outputs and counting any console.error or console.warn messages

Commands for saving yarn test outputs and counting any console.error or console.warn messages.

This gist provides commands for capturing and analyzing the output of your JavaScript testing process using yarn test. The first command saves all output from the test run, including both standard output and error messages, to a file named test_output.txt. This is useful for reviewing all feedback from the test process. The second command filters this output to count how many lines contain either console.error or console.warn, helping you quickly assess the number of errors or warnings generated during your tests. This approach is valuable for identifying potential issues in your codebase by focusing on explicit error and warning logs.

Save all test output to a file

yarn test >test_output.txt 2>&1

Save all test errors and warnings to a file

grep -E "console.error|console.warn" test_output.txt | wc -l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment