You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current VisualContent tests work, but they could be way better if they test if rendered content includes what we expect. More details below.
Requirements
Update all VisualContent tests, avoiding the usage of toMatchSnapshot where possible. It's highly likely that we don't need to use snapshots in any of the tests.
Tips
Here's how these tests could work:
This test will definitely break when we introduce changes to how content is rendered, so I'm not sure if it will be useful in the long term. I say we remove it.
This test will most likely break, just as before, but we could test if all content was rendered instead.
This means that, instead of just checking if a snapshot won't change, you could test if the number of elements rendered inside the .sl-visual-content element matches the number of blocks in the content object.
Testing this way, even if we add new block types and update the content object, the test will keep working, as long as all blocks are correctly rendered.
Instead of using a snapshot, you could select the first rendered block and check if it has exactly 40 words followed by an ellipsis (...).
Check src/VisualContent/index.tsx:97 to learn how the component truncates paragraph text, and do the same in your test.
It should be pretty similar to the last test, except it should only render as many words as the excerptLength prop.
This should be similar to the first test, where you asserts that the expected number of blocks are rendered.
The text was updated successfully, but these errors were encountered:
Description
Current VisualContent tests work, but they could be way better if they test if rendered content includes what we expect. More details below.
Requirements
toMatchSnapshot
where possible. It's highly likely that we don't need to use snapshots in any of the tests.Tips
Here's how these tests could work:
This test will definitely break when we introduce changes to how content is rendered, so I'm not sure if it will be useful in the long term. I say we remove it.
This test will most likely break, just as before, but we could test if all content was rendered instead.
This means that, instead of just checking if a snapshot won't change, you could test if the number of elements rendered inside the
.sl-visual-content
element matches the number of blocks in thecontent
object.Testing this way, even if we add new block types and update the
content
object, the test will keep working, as long as all blocks are correctly rendered.Instead of using a snapshot, you could select the first rendered block and check if it has exactly 40 words followed by an ellipsis (...).
Check
src/VisualContent/index.tsx:97
to learn how the component truncates paragraph text, and do the same in your test.It should be pretty similar to the last test, except it should only render as many words as the
excerptLength
prop.This should be similar to the first test, where you asserts that the expected number of blocks are rendered.
The text was updated successfully, but these errors were encountered: