// tester.js
class Tester {
static loggit(text) {
return text;
}
}
module.exports = new Tester();
When testing this singleton in Node.js using Jest
// tester.spec.js
const Tester = require('./tester.js');
describe('Tester testing', () => {
it('logs it', () => {
expect(Tester.loggit('test')).toEqual('test');
});
});
When running the test, I get an error saying "encountered a declaration exception. TypeError: Tester.loggit is not a function"
I tried using jest.requireActual to resolve it, but it's not fixing the error.
I don't want to export the class itself as it will be a singleton in my app.
Any input will be helpful.