Skip to content

Fix module export for oscilloscope.js to enable proper Jest coverage#5956

Open
stutijain2006 wants to merge 1 commit intosugarlabs:masterfrom
stutijain2006:OscilloscopeTest
Open

Fix module export for oscilloscope.js to enable proper Jest coverage#5956
stutijain2006 wants to merge 1 commit intosugarlabs:masterfrom
stutijain2006:OscilloscopeTest

Conversation

@stutijain2006
Copy link
Contributor

This PR updates oscilloscope.js to properly export the Oscilloscope class using module.exports.

Previously, the test file was loading the source dynamically using fs.readFileSync and new Function(), which prevented Jest from instrumenting the file for coverage. As a result, oscilloscope.js was showing 0% coverage, even though comprehensive tests already existed.

Changes Made-

  • Added proper JS Export
    module.exports = Oscilloscope;

-Updated the test file to import the module using:
const Oscilloscope = require("../oscilloscope.js");

-Removed dynamic evaluation via new Function() and fs.readFileSync() from tests.

Impact-
Jest can now correctly instrument oscilloscope.js.
Coverage for oscilloscope.js went from 0% to 76%.
Existing test suite is now reflected in coverage metrics.

Screenshot 2026-02-28 022514

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant