When creating a custom block, and subsequently writing a test for it, an error is thrown when I attempt to import the Edit component in Jest:
You tried to opt-in to unstable APIs as module "@wordpress/data" which is already registered.
This feature is only for JavaScript modules shipped with WordPress core.
Please do not use it in plugins and themes as the unstable APIs will be removed without a warning.
If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.
4 | import { useEffect, useState } from '@wordpress/element';
5 | import { InspectorControls } from '@wordpress/block-editor';
> 6 | import ServerSideRender from '@wordpress/server-side-render';
| ^
Jest will fail with this error and as such I'm unable to write any tests for my block.
What is your proposed solution?
Allow for tests to be written or provide a workaround to those that want to use ServerSideRender but also tests components that use it.
Additional Notes
I also notice that all the blocks in the core WP library that use ServerSideRender don't have any tests. Normally there's an included "tests" directory within the block's repository. See:
Relates to #57426. All the effort that the Gutenberg core team is putting into preventing people from using private/unstable APIs is punishing those of us who want to test our integration code.
What problem does this address?
When creating a custom block, and subsequently writing a test for it, an error is thrown when I attempt to import the Edit component in Jest:
Jest will fail with this error and as such I'm unable to write any tests for my block.
What is your proposed solution?
Allow for tests to be written or provide a workaround to those that want to use ServerSideRender but also tests components that use it.
Additional Notes
I also notice that all the blocks in the core WP library that use ServerSideRender don't have any tests. Normally there's an included "tests" directory within the block's repository. See:
https://github.com/WordPress/gutenberg/search?p=1&q=serversiderender
With this, can I presume this is a known issue?