x-dash icon indicating copy to clipboard operation
x-dash copied to clipboard

switch jest snapshots to use storyshots

Open apaleslimghost opened this issue 7 years ago • 3 comments

https://github.com/storybooks/storybook/tree/release/3.4/addons/storyshots

pros:

  • less custom x-dash magic is good

cons:

  • i do not trust storybook

apaleslimghost avatar Oct 09 '18 09:10 apaleslimghost

I think the latter is why I avoided it when first implementing snapshots...

We could get rid of the "magic" aspect and instead encourage/force components to include their own tests (which would resolve #152). There may be some repetition but that's OK, it's one code base so refactors are possible!

i-like-robots avatar Oct 09 '18 09:10 i-like-robots

how would you feel about adding something to x-test-utils to do this? then each component would have its own __tests__ folder that could do something like:

import { storySnapshotTests } from '@financial-times/x-test-utils';

describe('x-teaser', () => {
  storySnapshotTests();
});

edit: maybe make it more explicit:

import stories from '../stories';
import { storySnapshotTests } from '@financial-times/x-test-utils';

describe('x-teaser', () => {
  storySnapshotTests(stories);
});

apaleslimghost avatar Oct 11 '18 09:10 apaleslimghost

Pretty OK!

i-like-robots avatar Oct 11 '18 09:10 i-like-robots