Packages with top-level locked private APIs are not easily mockable in Jest tests by third parties.
I will fully admit even after looking through the private API code I'm not 100% sure why this is, but I've been able to reproduce it consistently, particularly with tests which depend on the @wordpress/block-editor package. It seems like something in jest.requireActual is possibly accessing these APIs in an incompatible way.
Step-by-step reproduction instructions
Write a Jest test depending on a mock of a package with top level private dependencies, such as @wordpress/block-editor
### Screenshots, screen recording, code snippet
_No response_
### Environment info
_No response_
### Please confirm that you have searched existing issues in the repo.
Yes
### Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Description
Packages with top-level locked private APIs are not easily mockable in Jest tests by third parties.
I will fully admit even after looking through the private API code I'm not 100% sure why this is, but I've been able to reproduce it consistently, particularly with tests which depend on the
@wordpress/block-editor
package. It seems like something injest.requireActual
is possibly accessing these APIs in an incompatible way.Step-by-step reproduction instructions
@wordpress/block-editor
describe( 'myTestSuite', () => { test( 'myTest', () => { render( );
} );
● Test suite failed to run