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

Tests failing with 'TypeError: Cannot read property 'isPrototypeOf' of null' after updating 3.2.0 #270

Closed
kizaonline opened this issue Jun 25, 2017 · 3 comments

Comments

@kizaonline
Copy link

I'm attempting to update to 3.2.0, but the following td.replace is now failing, has there been a change to how td.replace should be used?
const td = require('testdouble')

test.only('Should succeed when passed valid input', (t) => {
const aws = td.replace('aws-sdk').S3
...
Stack trace is:
TypeError: Cannot read property 'isPrototypeOf' of null
(node:70949) DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.
(node:70949) DeprecationWarning: crypto.Credentials is deprecated. Use tls.SecureContext instead.
at isNativePrototype (/apps/blob-uploader/node_modules/testdouble/lib/imitate/overwrite-children/gather-props.js:30:41)
at exports.default (/apps/blob-uploader/node_modules/testdouble/lib/imitate/overwrite-children/gather-props.js:17:11)
at exports.default (/apps/blob-uploader/node_modules/testdouble/lib/imitate/overwrite-children/index.js:37:64)
at imitate (/apps/blob-uploader/node_modules/testdouble/lib/imitate/index.js:33:35)
at /apps/blob-uploader/node_modules/testdouble/lib/imitate/index.js:34:12
at /apps/blob-uploader/node_modules/testdouble/lib/imitate/overwrite-children/index.js:38:83
at newValue (/apps/blob-uploader/node_modules/testdouble/lib/imitate/overwrite-children/copy-props.js:39:20)
at /apps/blob-uploader/node_modules/testdouble/lib/imitate/overwrite-children/copy-props.js:24:16
at /apps/blob-uploader/node_modules/lodash/transform.js:60:12
at /apps/blob-uploader/node_modules/lodash/_createBaseFor.js:17:11
at baseForOwn (/apps/blob-uploader/node_modules/lodash/_baseForOwn.js:13:20)

@searls
Copy link
Member

searls commented Jun 25, 2017 via email

@searls
Copy link
Member

searls commented Jun 26, 2017

Fixed by 737df04

Please keep in mind that testdouble.js is not intended for replacing third-party APIs like you're doing. Also, 3.2 performs a deep-replacement, and the aws-sdk module is absolutely massive. Each time you replace it, it'll probably take 1-2 seconds. I strongly advise you to create a wrapper around the third-party dependency and then wrap that instead. More reading on this here: Don't mock what you don't own

@searls searls closed this as completed Jun 26, 2017
@searls
Copy link
Member

searls commented Jun 26, 2017

Landed in 3.2.1

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