kiwigrid/gherkin-testcafe

How to use babel and gherkin-testcafe

Closed this issue · 1 comments

Hi there, is there any way to use babel and gherkin-testcafe? The reason why I'm asking that is due to UI tests are using some files that use the babel aliases and it fails when it tries to execute the test:

Error: Cannot find module '@helpers'
Require stack:
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\api\commons\controllers\DepartmentController.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\api\commons\controllers\index.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\ui\steps\departmentCategoryManagement\departmentCategoryManagement.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\node_modules\testcafe\lib\compiler\test-file\formats\es-next\compiler.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\node_modules\gherkin-testcafe\src\compiler.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\node_modules\gherkin-testcafe\src\rewire-compiler.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\node_modules\gherkin-testcafe\src\cli.js
- C:\Users\ylopezs\git\splunk\splunk2020\e2e\node_modules\gherkin-testcafe\main.js
    at Object.<anonymous> (C:\Users\ylopezs\git\splunk\splunk2020\e2e\api\commons\controllers\DepartmentController.js:1:1)

as you can see, I'm importing a file using the "@helpers" alias but can't be compiled

Hi @leonleo997

as far as I know, this is not possible with babel. But your babelrc files should be automatically picked up by the test file compiler.
The problem you are facing here is that the files are not bundled together, but are transpiled with babel to be run on node directly.

If you used typescript (which you did not as far as I can tell), then you could specify the paths in the tsconfig's paths section.

This is however not a gherkin-testcafe specific issue, but an issue you would also face with testcafe directly.