为什么出现SyntaxError:无法在模块外部使用import语句?

时间:2020-10-28 13:10:43

标签: javascript mongoose jestjs

我正在尝试运行mockingoose示例

> alonjest@1.0.0 test /home/milenko/pract/alonjest
> jest __tests__

 FAIL  .history/__tests__/user.test_20201028132815.js
  ● Test suite failed to run

   Details:

    /home/milenko/pract/alonjest/.history/__tests__/user.test_20201028132815.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import mockingoose from 'mockingoose';

Package.json

  "name": "alonjest",
  "version": "1.0.0",
  "description": "",
  "main": "user.js",
  "type": "module",
  "scripts": {
    "test": "jest __tests__"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "mongoose": "^5.10.11"
  },
  "devDependencies": {
    "jest": "^26.6.1",
    "mockingoose": "^2.13.2"
  }
}

Dir结构

node_modules
package.json
package-lock.json
__tests__
user.mjs

我的配置出了什么问题?

0 个答案:

没有答案