开玩笑`默认不是构造函数`第二次加载文件

时间:2018-12-20 03:31:32

标签: javascript class jestjs

我很难理解为什么会发生这种情况或我可以检查什么。我有一个正在用笑话测试的课程。通过仅导入文件,我将引发以下错误:

FAIL  server/web/test/IntegrationUiHelper.test.js
 ● Test suite failed to run

TypeError: _IntegrationUiHelper2.default is not a constructor

  at Object.<anonymous> (server/web/client/modules/processes/steps/UiStepHelper.js:106:1)
  at Object.<anonymous> (server/web/client/modules/processes/ProcessForm/ProcessFormStep.jsx:13:21)      at Object.<anonymous> (server/web/client/modules/processes/steps/components/stepOptions/integration/PatchOption.jsx:8:24)
  at Object.<anonymous> (server/web/client/modules/processes/ProcessForm/ApiParameter.jsx:8:20)
  at Object.<anonymous> (server/web/client/modules/processes/ProcessForm/ApiParameterList.jsx:5:21)
  at Object.<anonymous> (server/web/client/modules/processes/steps/components/stepOptions/IntegrationStepOptions.jsx:8:25)
  at Object.<anonymous> (server/web/client/modules/processes/steps/IntegrationUiHelper.js:7:31)
  at Object.<anonymous> (server/web/test/IntegrationUiHelper.test.js:2:28)
  at handle (node_modules/worker-farm/lib/child/index.js:44:8)
  at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:51:3)      at process.emit (events.js:182:13)
  at emit (internal/child_process.js:812:12)
  at process._tickCallback (internal/process/next_tick.js:63:19)

如您所见,尝试使用的构造函数已经由测试文件直接导入。它也用在UiStepHelper中,但在那里没有正确加载。

我还有其他一些测试套件,这些套件不会直接导入IntegrationUiHelper.js文件,而是会一直导入UiStepHelper.js并且测试运行良好。

失败的行如下-步骤在文件中定义,然后由导出的函数使用。

const steps = [
  ... // other UiHelper classes with the same design
  new IntegrationUiHelper().getStepObject(),
  ... // other UiHelper classes with the same design
];

0 个答案:

没有答案