mardi 31 mai 2016

How to properly test a module that requires newrelic with jest

I'm working migrating a bunch of unit tests from mockery to jest. When I jest a module that requires the new relic agent like so: require('newrelic'), I get downstream errors like :

  - TypeError: Cannot convert undefined or null to object
    at Object.<anonymous> (node_modules/newrelic/lib/config.js:165:33)
    at Runtime._execModule (node_modules/jest-cli/src/Runtime/Runtime.js:261:17)
    at Object.<anonymous> (node_modules/newrelic/lib/logger.js:18:14)
    at Object.<anonymous> (node_modules/newrelic/index.js:3:14)

What is the best way to deal with modules like newrelic which jest has a hard time mocking? What have other people done when they have both jest and newrelic in their stack?

Aucun commentaire:

Enregistrer un commentaire