开玩笑的测试-无法在模块外部使用import语句

时间:2020-08-11 10:38:33

标签: jestjs babeljs babel-jest jimp

我有一个开玩笑的测试

import React from 'react';

import Products from '../Products.js';

test('Should reorder list', () => {
  const products = new Products();
  ...
});

但是当我运行它时,我收到一条错误消息,提示我正在使用的库中不允许导入

  ● Test suite failed to run

    .../node_modules/jimp/es/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import configure from '@jimp/custom';
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

我的babel.config.json:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-object-rest-spread"]
}

我在做什么错?为何Jimp库无法使用该语法导入?

0 个答案:

没有答案