I have a node project with the following format:
structures/extendedClient.js
utils/feature.js
tests/feature.test.js
In extendedClient.js I have the following:
class extendedClient extends Client {
constructor(props) {
// constructor stuff
}
runFeature() {
require("../util/feature")(this);
}
}
module.exports = extendedClient;
In my feature.js I have the following:
module.exports = (client) => {
/**
*
* @param {require("../structures/extendedClient")} client
*/
function featureCore() {
// stuff (requires client variable)
}
featureCore();
}
I tried calling featureCore() from another location but it wouldn’t import properly so I temporarily put it here. However, now I can’t reference the function in any unit tests (Jest).
my feature.test.js file:
const { anotherFunction, featureCore } = require("./util/feature");
test('expect birthday core to be read', () => {
expect(birthdayReminderCore().toBe(3))
})
My test suite is throwing “TypeError: featureCore is not a function”.
I’m sure that I’m missing something glaringly obvious, was just hoping someone could point me in the right direction. Thanks!
New contributor