Skip to content

Support testing Slice API #37139

Dec 1, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

If the Slice API is disabled, the test should run with the Slice component being replaced by some dummy placeholder element for the purpose of snapshot testing.

Wouldn't that be the task of a Jest snapshot serializer? e.g. like https://github.com/tribou/jest-serializer-path

The code (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/slice.js#L8) could have a check for testing environment but if it can be achieved outside of that I'd prefer that.

If the Slice API is enabled, the test should run, replacing the Slice component with its actual value.

That won't easily be possible in a test environment, you need to mock the context provider(s) and have the informatio…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mudge
Comment options

@LekoArts
Comment options

@LekoArts
Comment options

Answer selected by LekoArts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #37138 on December 01, 2022 12:47.