Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

td.explain does not work on new instance of td.replace('lib') #323

Closed
stephan-nordnes-eriksen opened this issue Jan 17, 2018 · 2 comments
Closed

Comments

@stephan-nordnes-eriksen

Info:

It appears that td.explain does not seem to work on new instances (context) of replaced libraries.

Current behaviour:

let td = require('testdouble')
let someLibrary = td.replace('bull') ///Whichever library you want. I Had bull installed, so I tested with that
let instance = new someLibrary()
console.log('instance', instance, td.explain(instance), typeof(instance))
console.log(td.explain(someLibrary))

Running this results in;

$ node weirdness.js
instance testDouble {} { name: undefined,
  callCount: 0,
  calls: [],
  description: 'This is not a test double.',
  isTestDouble: false } object
{ name: 'bull: Queue',
  callCount: 1,
  calls: [ { args: [], context: testDouble {} } ],
  description: 'This test double `bull: Queue` has 0 stubbings and 1 invocations.\n\nInvocations:\n  - called with `()`.',
  isTestDouble: true }

Expected behaviour:

I expected something like the following:

$ node weirdness.js
instance testDouble {} { name: `bull: Queue context`,
  callCount: 0,
  calls: [],
  description: 'This test double `bull: Queue context` has 0 stubbings and 0 invocations.',
  isTestDouble: true } object
{ name: 'bull: Queue',
  callCount: 1,
  calls: [ { args: [], context: testDouble {} } ],
  description: 'This test double `bull: Queue` has 0 stubbings and 1 invocations.\n\nInvocations:\n  - called with `()`.',
  isTestDouble: true }

testdouble@3.3.2

@searls
Copy link
Member

searls commented Jan 17, 2018 via email

@searls
Copy link
Member

searls commented Jan 17, 2018

Duplicate of #48

@searls searls marked this as a duplicate of #48 Jan 17, 2018
@searls searls closed this as completed Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants