'unit testing a class export

file main.js:

class myClass {
    constructor(options) {
        super({
            ...options,
   ...
    myFuncToTest(objects) {}


if (require.main !== module) {
    // Export the constructor in compact mode
    /**
     * @param {Partial<utils.AdapterOptions>} [options={}]
     */
    module.exports = (options) => new myClass(options);
}

now I want to do a unit test of the myFuncToTest.

const main = require("./main.js");

how do I get a handle to the function? Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source