Bug 1672932 - [devtools] Don't use devtool-launchpad l10n fixtures in debugger jest tests. r=ladybenko.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 27 Oct 2020 11:04:38 +0000
changeset 554773 f0b7afda2b82175b83d8e67971a6ebf77831b370
parent 554772 c4b54c998a530bfa8f5777eafc9bf70efc91820a
child 554774 e332910641ba22c81562c4fa38d1955f85a1b228
push id37898
push userabutkovits@mozilla.com
push dateWed, 28 Oct 2020 09:24:21 +0000
treeherdermozilla-central@83bf4fd3b1fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko
bugs1672932
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1672932 - [devtools] Don't use devtool-launchpad l10n fixtures in debugger jest tests. r=ladybenko. The l10n module works properly in Node environment now, so we can directly use it. Depends on D94568 Differential Revision: https://phabricator.services.mozilla.com/D94570
devtools/client/debugger/jest-test.config.js
devtools/client/debugger/src/test/shim.js
--- a/devtools/client/debugger/jest-test.config.js
+++ b/devtools/client/debugger/jest-test.config.js
@@ -25,16 +25,19 @@ module.exports = {
   collectCoverageFrom: [
     "src/**/*.js",
     "!src/**/fixtures/*.js",
     "!src/test/**/*.js",
     "!src/components/stories/**/*.js",
     "!**/*.mock.js",
     "!**/*.spec.js",
   ],
+  transform: {
+    "\\.[jt]sx?$": "babel-jest",
+  },
   transformIgnorePatterns: ["node_modules/(?!(devtools-|react-aria-))"],
   setupTestFrameworkScriptFile: "<rootDir>/src/test/tests-setup.js",
   setupFiles: ["<rootDir>/src/test/shim.js", "jest-localstorage-mock"],
   snapshotSerializers: [
     "jest-serializer-babel-ast",
     "enzyme-to-json/serializer",
   ],
   moduleNameMapper: {
--- a/devtools/client/debugger/src/test/shim.js
+++ b/devtools/client/debugger/src/test/shim.js
@@ -1,17 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 // @flow
 
-import { readFileSync } from "fs";
-import path from "path";
-
 global.requestAnimationFrame = callback => setTimeout(callback, 0);
 global.isWorker = false;
 
 global.define = function() {};
 global.loader = {
   lazyServiceGetter: () => {},
   lazyGetter: (context, name, fn) => {
     try {
@@ -48,29 +45,23 @@ global.loader = {
         const module = require(_path);
         global[name] = destruct ? module[name] : module;
       }
     }
   },
 };
 
 global.DebuggerConfig = {};
-const rootPath = path.join(__dirname, "../../");
-function getL10nBundle() {
-  const read = file => readFileSync(path.join(rootPath, file));
 
-  try {
-    return read("./assets/panel/debugger.properties");
-  } catch (e) {
-    return read("../locales/en-US/debugger.properties");
-  }
-}
+// $FlowIgnore
+const { LocalizationHelper } = require("devtools/shared/l10n");
+global.L10N = new LocalizationHelper(
+  "devtools/client/locales/debugger.properties"
+);
 
-global.L10N = require("devtools-launchpad").L10N;
-global.L10N.setBundle(getL10nBundle());
 global.performance = { now: () => 0 };
 
 const { URL } = require("url");
 global.URL = URL;
 
 function mockIndexeddDB() {
   const store = {};
   return {