Open milahu opened 2 years ago
@milahu I like your idea! our test snapshot files are enormous because of the number of snapshots, and the different combinations of generator options.
If you're interested in giving it a shot and contributing this change, that would be great! I'm down to see what it looks like.
One note I think the format should be:
packages/core/src/__tests__/data/advanced-ref/file.raw.tsx
(moved into its own folder)packages/core/src/__tests__/data/advanced-ref/file.raw.snap.solidjs.jsx
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.svelte.svelte
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.vue2.vue
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.vue3.vue
One issue is that we run the same generators with multiple combinations of options. So for Vue3, we would have:
So we would have 1 file per combination, and its filename would encode these options:
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.vue3-api|options-typescript|false.vue
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.vue3-api|composition-typescript|false.vue
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.vue3-api|options-typescript|true.vue
packages/core/src/__tests__/data/advanced-ref/file.raw.snap.vue3-api|composition-typescript|true.vue
Those file names could get pretty long, but I think that's ok. π€
draft in https://github.com/milahu/mitosis/tree/test-snapshots-to-separate-files
i solved the "options problem" with optionsId
and objectHash(cleanOptions)
example files
src/__tests__/data/basic-for.raw.tsx
src/__tests__/__file_snapshots__/data/basic-for.solid.jsx
src/__tests__/__file_snapshots__/data/basic-for.solid.style-tag.tsx
nitpick: raw.tsx
should be mitosis.tsx
the folder layout is secondary as we would use a tool like storybook or component-party for postprocessing
I think this is pretty cool! Thank you for this initiative @milahu ππ½ . I'd be down to have this change in the core repository if you can bring it to life.
NOTE: we recently migrated to vitest
, but I think you should be able to use the jest helper library you used: https://vitest.dev/api/#expect-extend
Let me know if you encounter any issues π
This seems interesting, any progress @milahu ?
abandoned, sorry : /
actual: test inputs are stored in separate files with
tsx
file extension test outputs (snapshots) are stored in one file per framework withsnap
file extensionexpected: test outputs should be stored in separate files with
tsx
file extension test output files should have a similar file path as test input fileswhy: help with porting components to mitosis so the test outputs are accessible via the github blob API so its easier to
grep
for a desired output, for examplecreateEffect
in solidalternative: postprocess the
snap
files and generate pretty html docs with side-by-side comparisons of input and output code similar to https://party.sveltosis.dev/jest issue: https://github.com/facebook/jest/issues/2676
possible solution:
toMatchSpecificSnapshot
fromjest-specific-snapshot
storybook: https://github.com/storybookjs/storybook/pull/1584 typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/pull/2290example