Skip to content

Commit

Permalink
mock useGlobals in jest (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank99 authored Jun 7, 2023
1 parent f0bdcef commit a00eac5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/itwinui-react/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module.exports = {

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'useGlobals.js$': '<rootDir>/src/__mocks__/useGlobalsMock.js',
'^(\\.\\.?\\/.+)\\.jsx?$': '$1', // see https://github.com/kulshekhar/ts-jest/issues/1057
},

Expand Down
8 changes: 8 additions & 0 deletions packages/itwinui-react/src/__mocks__/useGlobalsMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
module.exports = {
// noop because we don't want to spam the terminal with warnings during tests
useGlobals: () => {},
};

0 comments on commit a00eac5

Please sign in to comment.