Currently if a HTML element is passed to t.snapshot it copies the code as is to the .md file.
I was hoping to pass a function to the serialiser so I could pretty print the content before it's saved to the .md file.
Example: app-header.spec.js.md
Example: html serialiser for Jest
It’s designed to do that, but it’s not exposed in AVA. Happy to work out details if you open an issue.
Ref: https://twitter.com/novemberborn/status/1017718535274065920
The library underlying t.snapshot() and t.deepEqual() is concordance. It was designed to be extensible (see @concordance/react, but we've never exposed an interface to do so within AVA.
Writing such extensions is a fair bit more difficult than for Jest's snapshot mechanism, but I guess it won't get easier until we start encouraging people to write their own 😄
Question though, how do we want to configure these extensions? Programmatically?
import {registerConcordancePlugin} from 'ava/extend'
Or in the configuration file, with a factory method pattern?
export default {
plugins: [
({registerConcordance}) => registerConcordance(…)
]
}
We'll also need some metadata regarding the plugin that's been registered, so that if AVA encounters a snapshot without the corresponding plugin being available, it can give a useful error message.
It's been a while since I've looked at the underlying code but these are the main questions I think.
Most helpful comment
The library underlying
t.snapshot()andt.deepEqual()is concordance. It was designed to be extensible (see@concordance/react, but we've never exposed an interface to do so within AVA.Writing such extensions is a fair bit more difficult than for Jest's snapshot mechanism, but I guess it won't get easier until we start encouraging people to write their own 😄
Question though, how do we want to configure these extensions? Programmatically?
Or in the configuration file, with a factory method pattern?
We'll also need some metadata regarding the plugin that's been registered, so that if AVA encounters a snapshot without the corresponding plugin being available, it can give a useful error message.
It's been a while since I've looked at the underlying code but these are the main questions I think.