带TypeScript的babel-plugin-rewire

时间:2019-11-14 18:49:42

标签: typescript jestjs babel babel-jest

我试图在使用Jest和TypeScript的应用程序中使用babel-plugin-rewire。当我即使没有使用就添加此插件ti .babelrc时,我的所有测试也会失败,并显示以下错误:

conf/jest.init.js:14
    /* istanbul ignore next */function _getGlobalObject() {try {if (!!global) {return global;}} catch (e) {try {if (!!window) {return window;}} catch (e) {return this;}}};var _RewireModuleId__ = null;function _getRewireModuleId__() {if (_RewireModuleId__ === null) {var globalVariable = _getGlobalObject();if (!globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__) {globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__ = 0;}_RewireModuleId__ = __$$GLOBAL_REWIRE_NEXT_MODULE_ID__++;}return _RewireModuleId__;}function _getRewireRegistry__() {var theGlobalVariable = _getGlobalObject();if (!theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__) {theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);}return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__;}function _getRewiredData__() {var moduleId = _getRewireModuleId__();var registry = _getRewireRegistry__();var rewireData = registry[moduleId];if (!rewireData) {registry[moduleId] = Object.create


SyntaxError: Unexpected token 'export'

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

可能是什么?

0 个答案:

没有答案