Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterate over all submodules in core/src/__tests__/data/blocks/* and run snapshot tests on each #36

Closed
mandx opened this issue Dec 10, 2020 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mandx
Copy link
Contributor

mandx commented Dec 10, 2020

It may be nice to ultimately just update these tests to read the data/blocks dir and run tests against each automatically so it's easier to manage these tests

@mandx mandx added good first issue Good for newcomers help wanted Extra attention is needed labels Dec 10, 2020
@luislpv22
Copy link

Hello,

I've made some progress on this, but right now you are running different test cases for each suite, so could you tell me how you'd like to manage that?

Example:
parse-jsx.test.ts is running a single test case on this block: button-with-metadata.raw.tsx
If we loop through /data/blocks, this suite (and all of them) would run a test case for every block.

Thanks.

@mandx
Copy link
Contributor Author

mandx commented Mar 8, 2021

Hi @luislpv22! First, apologies for the sparse text here, I guess it looks like more like a paper note than a proper ticket.

The idea is to enumerate all test blocks (all the modules/components in packages/core/src/__tests__/data, which should contain one component/block each), then enumerate all available targets (React, Vue, etc...) and for each of these combinations of (block, target) simply do what most of the tests are doing already:

  • Parse the current block as JSXLite code (for example, the Image block)
  • Use the parsed block to output a component in the current target (ex Vue)
  • Assert the generated component code matches the previous snapshot.

In packages/core/src/__tests__/ we have:

data/ 👈 This is where all the blocks live

👇 These are the tests modules that would be replaced by a single test module that enumerates blocks + targets:
builder.test.ts
html.test.ts
liquid.test.ts
react.test.ts
solid.test.ts
vue.test.ts

👇 This is a different type of test, this can be left as is.
parse-jsx.test.ts

I guess we would end up with something like:

data/ 👈 This is where all the blocks live
block-snapshots-tests.ts 👈 this would be the new module that iterates and generates the snapshot tests
parse-jsx.test.ts 👈 same file as before, unchanged.

(block-snapshots-tests.ts is a placeholder name btw)

I think for now just having a const array/set at the top of the block-snapshots-tests.ts, since the target list doesn't change that often.

@samijaber
Copy link
Contributor

Closing this because of the progress done on #484. It's not iterating over everything, but allowing each generator to opt-in to the blocks it needs to test, which helps account for discrepancies between them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants