-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Tests: Update full post content tests to use snapshots #1841
Conversation
6705c8d
to
8a1096c
Compare
@@ -93,110 +81,51 @@ describe( 'full post content fixture', () => { | |||
require( 'blocks' ); | |||
} ); | |||
|
|||
it( 'has 54 fixtures', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be obsolete, but we can give it a try. Whenever we add/remove file, we would have to update this number.
} ); | ||
} ); | ||
|
||
it( 'should be present for each block', () => { | ||
const errors = []; | ||
const blockTypes = getBlockTypes(); | ||
|
||
expect( blockTypes ).toHaveLength( 51 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this check would help us control how many block types are processed. If we don't want to keep it updated whenever block type is added/removed, we should at least verify if this number is greater than 0.
8a1096c
to
09d8466
Compare
It looks like
I'm wondering if we can read them from snaphshot... |
I am pretty disappointed with Jest snapshots for this particular task. They break most of the design goals of this test suite:
The structure of this test suite (one file that processes all of these fixtures) is part of the problem. I'm fine with any solution or improvement here that decreases the complexity while preserving the above goals, but I don't think this is it. I'd rather see us using Jest snapshots for component testing as per their original purpose and as previously discussed at #1788. |
@nylen I must agree with you. If we didn't have to share all fixtures with PHP codebase this might work as expected, but given that Jest produces one snapshot file per test suite it doesn't make sense to promote usage of snapshots here. Test file looks much cleaner with the changes applied in my opinion, so it might be a nice improvement if JS was our only concern here. Thanks for leaving your valuable feedback here. 👍 |
See #2018 for more discussion about using snapshots, this time for component testing. |
…edia_edit_icon_when_block_is_selected [Media Edit Icon] Show the media edit icon only if the block is selected
This PR updates full post content tests to use snapshots. Diff is quite big, but changes were quite trivial:
Testing
We need to verify if snapshots were properly created. From what I checked, they should be good.
Execute:
npm run test-unit
and make sure it still works.