shim.js (870B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 const { 6 setMocksInGlobal, 7 } = require("devtools/client/shared/test-helpers/shared-node-helpers"); 8 setMocksInGlobal(); 9 10 const { LocalizationHelper } = require("devtools/shared/l10n"); 11 global.L10N = new LocalizationHelper( 12 "devtools/client/locales/debugger.properties" 13 ); 14 15 const { URL } = require("url"); 16 global.URL = URL; 17 18 // JSDOM doesn't seem to have those functions that are used by codeMirror. 19 // See https://github.com/jsdom/jsdom/issues/3002 20 document.createRange = () => { 21 const range = new Range(); 22 23 range.getBoundingClientRect = jest.fn(); 24 25 range.getClientRects = jest.fn(() => ({ 26 item: () => null, 27 length: 0, 28 })); 29 30 return range; 31 };