You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a service that uses aws-sdk (2.278.1 right now). I would like to test-double the aws-sdk dependency in this service so that I can write true unit tests.
Issue
The td.replace('aws-sdk') call in the initialization of the test fixture throws the following exception:
TypeError: Method get TypedArray.prototype.length called on incompatible receiver [object Object]
at Uint8Array.get length [as length] (<anonymous>)
at isArrayLike (C:\Home\TestProject\node_modules\lodash\isArrayLike.js:30:42)
at keys (C:\Home\TestProject\node_modules\lodash\keys.js:34:10)
at baseAssign (C:\Home\TestProject\node_modules\lodash\_baseAssign.js:14:39)
at baseClone (C:\Home\TestProject\node_modules\lodash\_baseClone.js:122:32)
at Object.clone (C:\Home\TestProject\node_modules\lodash\clone.js:33:10)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\create-imitation.js:20:33)
at imitate (C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:12:44)
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:15:16
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\index.js:18:85
at newValue (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:30:22)
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:9:36
at C:\Home\TestProject\node_modules\lodash\transform.js:60:12
at C:\Home\TestProject\node_modules\lodash\_createBaseFor.js:17:11
at baseForOwn (C:\Home\TestProject\node_modules\lodash\_baseForOwn.js:13:20)
at Object.transform (C:\Home\TestProject\node_modules\lodash\transform.js:59:39)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:5:54)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\index.js:17:29)
at imitate (C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:14:33)
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:15:16
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\index.js:18:85
at newValue (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:30:22)
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:16:24
at C:\Home\TestProject\node_modules\lodash\transform.js:60:12
at C:\Home\TestProject\node_modules\lodash\_createBaseFor.js:17:11
at baseForOwn (C:\Home\TestProject\node_modules\lodash\_baseForOwn.js:13:20)
at Object.transform (C:\Home\TestProject\node_modules\lodash\transform.js:59:39)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:5:54)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\index.js:17:29)
at imitate (C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:14:33)
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:15:16
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\index.js:18:85
at newValue (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:30:22)
at C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:16:24
at C:\Home\TestProject\node_modules\lodash\transform.js:60:12
at C:\Home\TestProject\node_modules\lodash\_createBaseFor.js:17:11
at baseForOwn (C:\Home\TestProject\node_modules\lodash\_baseForOwn.js:13:20)
at Object.transform (C:\Home\TestProject\node_modules\lodash\transform.js:59:39)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\copy-props.js:5:54)
at Object.exports.default (C:\Home\TestProject\node_modules\testdouble\lib\imitate\overwrite-children\index.js:17:29)
at Object.imitate [as default] (C:\Home\TestProject\node_modules\testdouble\lib\imitate\index.js:14:33)
at replaceModule (C:\Home\TestProject\node_modules\testdouble\lib\replace\module\index.js:16:38)
at Object.default_1 [as replace] (C:\Home\TestProject\node_modules\testdouble\lib\replace\index.js:10:33)
at Context.beforeEach (C:\Home\TestProject\test\wm\gateways\sns-gateway.spec.js:19:22)
Environment
node -v output: 8.11.1
npm -v (or yarn --version) output: 5.6.0
npm ls testdouble (or yarn list testdouble) version: testdouble@3.8.1
npm ls aws-sdk: aws-sdk@2.278.1
Failing Test
Code-fenced Examples
vartd=require('testdouble');// this call fails with the error message described above.td.replace('aws-sdk');
The text was updated successfully, but these errors were encountered:
AFAICT, this is a bug in either lodash or the custom array type used by the aws package, and outside the confines of testdouble's responsibilities. I say that because testdouble.js is not designed to fake third party libraries. Even though it often technically can replace a third-party dep, the behavior isn't supported.
Thanks for the "Don't mock..." link, and you are right about this. Coincidentally, this is exactly what I did to continue development. Wrap the aws-sdk dependency in a gateway class and mock that instead.
Description
I have a service that uses aws-sdk (2.278.1 right now). I would like to test-double the aws-sdk dependency in this service so that I can write true unit tests.
Issue
The td.replace('aws-sdk') call in the initialization of the test fixture throws the following exception:
Environment
node -v
output: 8.11.1npm -v
(oryarn --version
) output: 5.6.0npm ls testdouble
(oryarn list testdouble
) version: testdouble@3.8.1npm ls aws-sdk
: aws-sdk@2.278.1Failing Test
Code-fenced Examples
The text was updated successfully, but these errors were encountered: