consola icon indicating copy to clipboard operation
consola copied to clipboard

Upgrading to consola v3 breaks testing environment

Open gbenson-ir opened this issue 1 year ago • 4 comments

Environment

Node v18.15.0 NPM v8.19.2 Consola v3.1.0

Reproduction

  1. Clone https://github.com/gbenson-ir/consola-v3-bug-reproduction
  2. Enter the directory
  3. Run npm i
  4. Run npm run test

Describe the bug

Since upgrading to v3 of consola, I am unable to run my unit tests. My tests fail and I receive the error "Cannot find module 'consola'".

This happens whether or not I use the new named exports.

Upgrading consola is the only change I have made to my project; before the upgrade I did not have the issue, following the upgrade I do. Prior to the upgrade I was using consola v2.15.3.

Additional context

I'm using Jest to run my unit tests. In my actual project I'm using TypeScript, but in the repo linked above it's a simple javascript project that also uses Jest (and babel-jest to transform the JS) and the issue is still present.

Logs

Cannot find module 'consola' from 'src/logger.test.js'

  2 | import { logger } from './logger';
  3 |
> 4 | jest.mock('consola', () => ({
    |      ^
  5 | 	consola: {
  6 | 		log: jest.fn()
  7 | 	}

  at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
  at Object.mock (src/logger.test.js:4:6)

gbenson-ir avatar Jun 07 '23 19:06 gbenson-ir