Open OmgImAlexis opened 6 years ago
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.
I'm tentatively adding this to the 4.0 milestone, but I reckon it won't make it. We're removing our built-in React support in AVA 4 so we'd want something like this to continue supporting React projects.
See a stalled attempt in https://github.com/avajs/ava/pull/2428.
I see a fix got merged, but this issue wasn't closed. Is it documented anywhere?
Err.. maybe it wasn't merged? ๐
I see a fix got merged, but this issue wasn't closed. Is it documented anywhere?
Err.. maybe it wasn't merged? ๐
Concordance needs a hefty dose of maintenance, though the extensibility APIs may not change much. So yea the issue is still open and this could be picked up by anybody but it's not currently a priority for me (insofar as a side-project can have priorities).
Description
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.Relevant Links
Example: app-header.spec.js.md
Example: html serialiser for Jest
Ref: https://twitter.com/novemberborn/status/1017718535274065920