From 7ac33570cb4bb4cbafaf393217c5fffba9d0b08b Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 21 Jan 2026 16:57:06 -0500 Subject: [PATCH] test: Mock `@wordpress` modules throwing import errors Address an import error by mocking the relevant `@wordpress` modules. This is likely incompatibility between Vitest configuration and the packages. ``` FAIL src/utils/editor.test.jsx [ src/utils/editor.test.jsx ] TypeError: Module "file:./GutenbergKit/node_modules/@wordpress/blocks/build-module/api/i18n-block.json" needs an import attribute of type "json" ``` --- src/utils/editor.test.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/editor.test.jsx b/src/utils/editor.test.jsx index b15757d3..6c7b52cb 100644 --- a/src/utils/editor.test.jsx +++ b/src/utils/editor.test.jsx @@ -13,12 +13,15 @@ import { getGBKit, getPost } from './bridge'; import { getDefaultEditorSettings } from './editor-settings'; import { unregisterDisallowedBlocks } from './blocks'; +vi.mock( '@wordpress/blocks', () => ( {} ) ); vi.mock( '@wordpress/editor', () => ( { store: { name: 'core/editor' }, } ) ); vi.mock( import( '@wordpress/data' ), { spy: true } ); vi.mock( '@wordpress/preferences' ); -vi.mock( '@wordpress/block-library' ); +vi.mock( '@wordpress/block-library', () => ( { + registerCoreBlocks: vi.fn(), +} ) ); vi.mock( './blocks' ); vi.mock( './bridge' ); vi.mock( './editor-settings' );