Best way to import (or mock) a shimming module in test?

Here’s the situation:

  1. The purpose is to write a service
  2. in this service, a 3rd party library was introduced (device.js)
  3. I use ember-cli-node-assets to add this tiny lib into vendor tree
  4. I use app.import to import this tiny lib, also app.import a shims to wrap this lib into ES2015 module
  5. import this shimming module in this service
  6. now tests running in browser are fine
  7. tests running in local CLI (macOS w/ phantomjs) are fine too (I was thought it will fails too! surprise)
  8. tests running in CI (jenkins on ubuntu 16.04 w/ same version of node & yarn & phantomjs) are failed when tests cover the part involved with the 3rd party module

I known this 3rd-party lib is depends on document and user agent, but I think phantomjs can handle that for me, I’m also try to access global window.device successfully, the real problem is tests failed because of:

undefined is not a function (evaluating '')

anyone knows how to actually import (or even mock this module) under this situation?