stub getComputedStyle due to JSDOM slowness

refs DE-1286

Change-Id: I4db742f74055de46cf15adbba6f857416c01e178
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/296699
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Alex Slaughter <aslaughter@instructure.com>
QA-Review: Aaron Ogata <aogata@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
Aaron Ogata 2022-07-20 19:04:30 -07:00
parent b0f4c77f6b
commit 1a46d87459
2 changed files with 13 additions and 1 deletions

View File

@ -57,7 +57,7 @@ module.exports = {
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'./packages/validated-apollo/src/ValidatedApolloCleanup.js',
'<rootDir>/jest/stubRecursiveTimers.js'
'<rootDir>/jest/stubInstUi.js'
],
testMatch: ['**/__tests__/**/?(*.)(spec|test).[jt]s?(x)'],

View File

@ -16,10 +16,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// https://github.com/instructure/instructure-ui/blob/v7.18.0/packages/ui-dom-utils/src/addPositionChangeListener.js
// This file creates a recursive listener that is never ending, causing jest.runAllTimers() to run infinitely long.
jest.mock('@instructure/ui-dom-utils/lib/addPositionChangeListener', () => ({
addPositionChangeListener: () => ({ remove: () => {} })
}))
// https://github.com/instructure/instructure-ui/blob/v7.18.0/packages/ui-dom-utils/src/addResizeListener.js
// This file creates a recursive listener that is never ending, causing jest.runAllTimers() to run infinitely long.
jest.mock('@instructure/ui-dom-utils/lib/addResizeListener', () => ({
addResizeListener: () => ({ remove: () => {} })
}))
// https://github.com/jsdom/jsdom/issues/3234
// JSDOM getComputedStyle() is painfully slow and our tests don't really need it.
// If you ever need it in the future, use jest.unmock() in the file that needs it
// or be prepared to fix the build speed regression in another way.
jest.mock('@instructure/ui-dom-utils/lib/getComputedStyle', () => ({
getComputedStyle: () => ({ getPropertyValue: () => void 0 })
}))