Skip to content

Commit 9d7ae03

Browse files
authored
Fix JS tests on fresh npm installs (#2280)
* Updated package-lock.json * Mock @wordpress/components instead of @wordpress/a11y Turns out `speak` was never mocked. * Mock actual a11y module used by `@wordpress/components` * Remove unneeded mockup * Shorten path to used module
1 parent 07da70d commit 9d7ae03

File tree

3 files changed

+5172
-6228
lines changed

3 files changed

+5172
-6228
lines changed

client/entrypoints/payment-request-settings/__tests__/payment-request-button-preview.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import { useStripe } from '@stripe/react-stripe-js';
44
import PaymentRequestsButtonPreview from '../payment-request-button-preview';
55
import { shouldUseGooglePayBrand } from '../utils/utils';
66

7-
jest.mock( '@wordpress/a11y', () => ( {
8-
...jest.requireActual( '@wordpress/a11y' ),
7+
// We need to mock the actual module being used by `<Notice />` in the `@wordpress/components` module
8+
const realPathToA11yModule =
9+
'@wordpress/components/node_modules/@wordpress/a11y';
10+
11+
jest.mock( realPathToA11yModule, () => ( {
12+
...jest.requireActual( realPathToA11yModule ),
913
speak: jest.fn(),
1014
} ) );
1115

client/settings/customization-options-notice/__tests__/customization-options-notice.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ jest.mock( '@woocommerce/data', () => ( {
99
OPTIONS_STORE_NAME: 'wc/admin/options',
1010
} ) );
1111

12-
jest.mock( '@wordpress/a11y', () => ( {
13-
...jest.requireActual( '@wordpress/a11y' ),
14-
speak: jest.fn(),
15-
} ) );
16-
1712
describe( 'CustomizationOptionsNotice', () => {
1813
beforeEach( () => {
1914
useDispatch.mockImplementation( () => ( {

0 commit comments

Comments
 (0)