我找到了一种使用babel-plugin-rewire模块模拟我的私有函数的方法。
返回实际的模块而不是模拟模块,从而绕过对模块是否应接收模拟实现的所有检查。
I think this might be related to jest and rewire. I've googled and found some posts that there is a babel plugin for this. Look like ts-jest cannot do anything in this case collinalexbell commented Feb 3, 2020 bump Author DavidBabel commented Feb 3, 2020 Well, if you use typescr...
The babel-plugin-rewire also does not work for me. Is there any other solutions out there to test that a function was called by another function within the same module? This honestly seems like it should work or that there should be a babel plugin out there that does this. Any help ...
config.presets = ["@babel/preset-env"]; } if (process.env.TEST_BACKEND) { config.plugins = ["babel-plugin-rewire"]; } module.exports = config; 5 changes: 5 additions & 0 deletions 5 config/jest-backend.config.js Original file line numberDiff line numberDiff line change @@ -0,0 ...
FAIL test/UI.test.tsx ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files,...
config.presets = ["@babel/preset-env"]; } if (process.env.TEST_BACKEND) { config.plugins = ["babel-plugin-rewire"]; } module.exports = config; 5 changes: 5 additions & 0 deletions 5 config/jest-backend.config.js Original file line numberDiff line numberDiff line change @@ -0,0 ...
config.presets = ["@babel/preset-env"]; } if (process.env.TEST_BACKEND) { config.plugins = ["babel-plugin-rewire"]; } module.exports = config; 5 changes: 5 additions & 0 deletions 5 config/jest-backend.config.js Original file line numberDiff line numberDiff line change @@ -0,0 ...