jest-simple-reporter
Cobbled together while I was trying to write an errorformat to use with Jest and Neomake in populating a Neovim quickfix window. This reporter just strips output down to a colon-separated list of values for each fixture.
Bound not to properly handle all situations. Really just a stop-gap until (hopefully) Jest implements a simplified output mode. Feel free to use and extend, PRs always welcome!
Install
npm -i --save-dev jest-simple-reporter
or
yarn add --dev jest-simple-reporter
Configure
Presuming you have Jest configured via package.json
:
"jest":
Sample Output
/home/basie/foo/mobile/src/components/FlargleArgle/FlargleArgle.test.js:::I:FlargleArgle > Worfle:matches the last snapshot/home/basie/foo/mobile/src/components/FlargleArgle/FlargleArgle.test.js:52:1:E:Expected value to be : 1 Received: <Loading />/home/basie/foo/mobile/src/components/FlargleArgle/FlargleArgle.test.js:::I:FlargleArgle:returns a message when no flargles are available/home/basie/foo/mobile/src/components/FlargleArgle/FlargleArgle.test.js:::I:FlargleArgle:marks the flargle read on touch/home/basie/foo/mobile/src/components/FlargleArgle/FlargleArgle.test.js:74:3:E:Expected mock /home/basie/foo/mobile/src/components/FlargleArgle/FlargleArgle.test.js:::I:FlargleArgle:calls fetchMore when scrolled to end of list
Currently I believe no line:col is available on test status 'passed', which could be rectified eventually.
Configuring Neomake
An errorformat that would work with this output might look like this:
let g:neomake_javascript_jest_maker = {
\ 'exe': './node_modules/jest-cli/bin/jest.js',
\ 'errorformat':
\ '%f:%l:%c:%t:%m,' .
\ '%-G%.%#'
\ }
let g:neomake_javascript_enabled_makers = ['jest']
This just means:
filepath:line:column:type:message
ignore any non-matching line
Note that setting neomake_javascript_enabled_makers
will override the default makers like eslint, so you might need to explicitly include those. It would also only display errors, since 'info' (I) lines generated by passing tests would be ignored by the second part of the errorformat. If I can find a way for the reporter to receive a line and column number, I'll update.
You could presumably use the errorformat string in a compiler for Vim too.