You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
index.js exports overwrite exports in jest context #75
I have made a local patch with this interface rather:
const supportedAlgorithms = {};
module.exports = function SHA (algorithm) {
algorithm = algorithm.toLowerCase()
var Algorithm = supportedAlgorithms[algorithm]
if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
return new Algorithm()
}
module.exports.sha = supportedAlgorithms.sha = require('./sha')
module.exports.sha1 = supportedAlgorithms.sha1 = require('./sha1')
module.exports.sha224 = supportedAlgorithms.sha224 = require('./sha224')
module.exports.sha256 = supportedAlgorithms.sha256 = require('./sha256')
module.exports.sha384 = supportedAlgorithms.sha384 = require('./sha384')
module.exports.sha512 = supportedAlgorithms.sha512 = require('./sha512')
And now my tests can retrieve my class and run as expected. It seems that the exports variable is only for simplicity and scope level check of support, so it wouldn't break consumption in my opinion.
I'm not sure what to do from there, I'd rather not make a fork (especially that this is not a first level dependency, so I'd have to make a dirtier hack in my package to ensure which version is consumed) but it also seems that this package does not get much attention these days. I'm happy to open a PR, but I would also like to have your feedback first, to find the best option for all of us.
Activity
test(Build): prevent ESM build test failure
ChALkeR commentedon Nov 26, 2024
This honestly looks like a jest bug