I have a very simple auth middleware with an export default () anonymous function: export default () => async (req, res, next) => { try { // some auth implementation… does not matter } else { throw new Error(‘No “Bearer” token passed as header’) } next() } catch (err) { next(err) } } I want […]
Testing is vital for ensuring code reliability and correctness. Mocking frameworks are key in unit testing, enabling developers to create mock objects and define their behavior. This article explores two popular mocking frameworks: Mockito and MockK which are well-known libraries in unit testing, with Mockito tailored for Java and MockK for Kotlin. We will be […]