How to use typescript Path aliases in Cucumber?

雨燕双飞 提交于 2021-02-11 12:28:33

问题


I need to use Cucumber in a project that uses path aliasing. As soon as I would import one of the path aliased modules, I get an error

I have tried solution in this answer, but I am running into another problem: Whenever I use the

   --require-module tsconfig-paths/register \

part, I suddenly get

    TypeError: cucumber_1.Given is not a function

error whenever I try to run the features.

(The error changes to TypeError: Given is not a function when I use the const { Given } = require('cucumber') syntax)

Is there any other solution for path aliasing in Cucumber, or is there a fix to the is not a function problem?


回答1:


Turns out I was using cucumber.js file at root as config, which was interfering with tsconfig-paths/register: tsconfig then picked up the cucumber.js file for from 'cucumber', instead of the cucumber module.

So the fix is to write all the --require-module options to the command line instead



来源:https://stackoverflow.com/questions/56873582/how-to-use-typescript-path-aliases-in-cucumber

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!