Financial-Times / x-dash

:x::heavy_minus_sign::newspaper: shared front-end components for FT.com and the FT Apps
https://financial-times.github.io/x-dash
38 stars 6 forks source link

switch jest snapshots to use storyshots #196

Open apaleslimghost opened 5 years ago

apaleslimghost commented 5 years ago

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

pros:

cons:

i-like-robots commented 5 years ago

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!

apaleslimghost commented 5 years ago

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);
});
i-like-robots commented 5 years ago

Pretty OK!