-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Do you want to request a feature or report a bug?
Bug about Manual Mocks with Filehound
What is the current behavior?
FAIL __tests__\methods\createFromJSON.ts
● Test suite failed to run
TypeError: sourceMap.map.originalPositionFor is not a function
1 | 'use strict';
> 2 | const filehound = jest.genMockFromModule('filehound');
3 |
4 | // temp files
5 | let result;
at mapSourcePosition (node_modules/source-map-support/source-map-support.js:213:42)
at wrapCallSite (node_modules/source-map-support/source-map-support.js:357:20)
at node_modules/source-map-support/source-map-support.js:392:26
at Array.map (<anonymous>)
at Function.prepareStackTrace (node_modules/source-map-support/source-map-support.js:391:24)
at Object.setBounds (node_modules/bluebird/js/release/debuggability.js:677:42)
at Object.<anonymous>.module.exports (node_modules/bluebird/js/release/promise.js:772:11)
at Object.<anonymous> (node_modules/bluebird/js/release/bluebird.js:9:36)
at Object.<anonymous> (node_modules/filehound/lib/filehound.js:13:17)
at Object.<anonymous> (node_modules/filehound/index.js:1:107)
at Object.<anonymous> (__mocks__/filehound.js:2:24)
at Object.<anonymous> (lib/MediaScan.js:44:17)
at Object.<anonymous> (__tests__/__helpers__/_constants.ts:6:21)
at Object.<anonymous> (__tests__/methods/createFromJSON.ts:59:20)
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.
No so much, just create a filehound.js inside a __mocks__ folder
// __mocks__/filehound.js
'use strict';
const filehound = jest.genMockFromModule('filehound');
// temp files
let result;
function find() {
if (result !== undefined){
return Promise.resolve(result);
}
// if nothing provided , throw error
return Promise.reject(new Error("VAUDOU"));
}
function __setResult(ExpectedResult) {
result = ExpectedResult;
}
filehound.__setResult = __setResult;
filehound.find = find;
module.exports = filehound;What is the expected behavior?
It should work.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest version : 22.3.0
Node version : 8.9.3
NPM version : 5.6.0
OS : Windows 10 Version 1709
My jest.config.js :
// jest.config.js
module.exports = {
verbose: true,
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"^.+\\.(ts|tsx)$": "<rootDir>/__tests__/__helpers__/preprocessor.js"
},
"testMatch": [
"<rootDir>/__tests__/**/*.(ts|tsx|js)"
],
"testPathIgnorePatterns": ["<rootDir>/node_modules/", "<rootDir>/__tests__/__helpers__/"],
"automock": true, // just because I'm lazy to always add the 2 lines of mock modules ^^
"unmockedModulePathPatterns": ['bluebird']
// "collectCoverage": true
};Edit : Without unmockedModulePathPatterns, I got TypeError: Cannot set property 'noConflict' of undefined like Issue 90