JEST – SyntaxError: Unexpected token ‘export’ with uuid library

Thanks to this reply:
https://stackoverflow.com/a/54117206/15741905

I started googling for similar fixes and ended up here:
https://github.com/uuidjs/uuid/issues/451

And this solved my problem: https://github.com/uuidjs/uuid/issues/451#issuecomment-1112328417

// jest.config.js
{
//................
  moduleNameMapper: {
    // Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
    "uuid": require.resolve('uuid'),
  }
}

Tough I would still be happy if there is solution to this by using jest-babel.

Because I had to carry jest configs from package.json to a seperate .js file.

Edit:
According to this github issue compatibility issue has been solved with the latest release of the uuid library.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)