Skip to content

Commit 5c1405b

Browse files
committed
Fix module export for reflection.js to enable proper Jest coverage reporting
1 parent f488f0b commit 5c1405b

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

js/widgets/__tests__/reflection.test.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@
2020
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2121
*/
2222

23-
const fs = require("fs");
24-
const path = require("path");
25-
26-
// Load the ReflectionMatrix class by reading the source and evaluating it
27-
const source = fs.readFileSync(path.resolve(__dirname, "../reflection.js"), "utf-8");
28-
// We put ReflectionMatrix in global scope
29-
new Function(
30-
source + "\nif (typeof global !== 'undefined') { global.ReflectionMatrix = ReflectionMatrix; }"
31-
)();
23+
const ReflectionMatrix = require("../reflection");
3224

3325
// Mock globals
3426
global._ = str => str;

js/widgets/reflection.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,3 +707,6 @@ class ReflectionMatrix {
707707
return this.sanitizeHTML(html);
708708
}
709709
}
710+
if (typeof module !== "undefined" && module.exports) {
711+
module.exports = ReflectionMatrix;
712+
}

0 commit comments

Comments
 (0)