kiwigrid/gherkin-testcafe

Invalid argument type

Opened this issue · 6 comments

I a getting following error on executing 'gherkin-testcafe firefox tests/steps/sampletest2.js tests/steps/sampletest2.feature' command

I even tried reinstalling all node_modules as it is mentioned by @ampc in #28. But it didn't work.

Appreciate anyone's help on this

ERROR TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined at assertPath (path.js:39:11) at Object.relative (path.js:497:5) at getDefinitionLineAndUri (C:\Users\mohamedh\Desktop\testcafe2\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:184:27) at buildStepDefinitionConfig (C:\Users\mohamedh\Desktop\testcafe2\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:124:7) at SupportCodeLibraryBuilder.defineStep (C:\Users\mohamedh\Desktop\testcafe2\node_modules\cucumber\lib\support_code_library_builder\index.js:51:79) at Object.<anonymous> (C:\Users\mohamedh\Desktop\testcafe2\tests\steps\sampletest2.js:7:1) at Module._compile (internal/modules/cjs/loader.js:688:30) at Module._compile (C:\Users\mohamedh\AppData\Roaming\npm\node_modules\testcafe\node_modules\source-map-support\source-map-support.js:521:25) at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32) at tryModuleLoad (internal/modules/cjs/loader.js:537:12) at Function.Module._load (internal/modules/cjs/loader.js:529:3) at Module.require (internal/modules/cjs/loader.js:636:17) at require (internal/modules/cjs/helpers.js:20:18) at stepFiles.forEach.stepFile (C:\Users\mohamedh\AppData\Roaming\npm\node_modules\gherkin-testcafe\src\compiler.js:122:7) at Array.forEach (<anonymous>) at GherkinTestcafeCompiler._loadStepDefinitions (C:\Users\mohamedh\AppData\Roaming\npm\node_modules\gherkin-testcafe\src\compiler.js:119:20) at GherkinTestcafeCompiler.getTests (C:\Users\mohamedh\AppData\Roaming\npm\node_modules\gherkin-testcafe\src\compiler.js:61:10) at Bootstrapper._getTests (C:\Users\mohamedh\AppData\Roaming\npm\node_modules\testcafe\src\runner\bootstrapper.js:81:41) at process._tickCallback (internal/process/next_tick.js:68:7)

Could you share your sampletest2.js file, @Mohamed-Haaziq?

I've got the same when I run:
gherkin-testcafe chrome .\tests**.steps.js .\tests**.feature

ERROR Cannot prepare tests due to an error.

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received type undefined
at getDefinitionLineAndUri (C:\Users\yauhen.barysik\Documents\QA AUTOMATION\euromoney.midas.clientapps\E2ETests\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:184:27)
at buildStepDefinitionConfig (C:\Users\yauhen.barysik\Documents\QA AUTOMATION\euromoney.midas.clientapps\E2ETests\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:124:7)
at SupportCodeLibraryBuilder.defineStep (C:\Users\yauhen.barysik\Documents\QA AUTOMATION\euromoney.midas.clientapps\E2ETests\node_modules\cucumber\lib\support_code_library_builder\index.js:51:79)
at Object. (C:\Users\yauhen.barysik\Documents\QA AUTOMATION\euromoney.midas.clientapps\E2ETests\tests\steps\dropdown-list-expanded.steps.js:7:1)
at Function._execAsModule (C:\Users\yauhen.barysik\AppData\Roaming\npm\node_modules\testcafe\src\compiler\test-file\api-based.js:50:13)
at ESNextTestFileCompiler._runCompiledCode (C:\Users\yauhen.barysik\AppData\Roaming\npm\node_modules\testcafe\src\compiler\test-file\api-based.js:150:42)
at ESNextTestFileCompiler.execute (C:\Users\yauhen.barysik\AppData\Roaming\npm\node_modules\testcafe\src\compiler\test-file\api-based.js:174:21)
at testFiles.forEach (C:\Users\yauhen.barysik\AppData\Roaming\npm\node_modules\gherkin-testcafe\src\compiler.js:154:26)
at compilerResult.externalCompilers.map (C:\Users\yauhen.barysik\AppData\Roaming\npm\node_modules\gherkin-testcafe\src\compiler.js:153:17)

I'm using windows 10.

Could you nail down which feature file is causing the problem and share it with me, @eugeneborisik ?

When I install this package globally (using npm install -g or yarn global add) I get the same error as @eugeneborisik when trying to run the google example tests.

This error also appears when installing in any other folder separate from the tests (e.g. package installed at C:\package and example tests stored under C:\tests).

However, when I install the package locally to the tests (npm install or yarn add), everything runs fine. Is this a known limitation of this package? Can it only be installed locally?

Did you also install gherkin globally, @microhod?
The gherkin package is a peer dependency of gherkin-testcafe and has to be accessible by gherkin-testcafe. In this case that means that gherkin has to be installed globally, too.
Please make also sure that you use the globally installed version of gherkin in your step implementations.

Hi Lukas,
This is Yogi, I bump into the same issue, I tried updating my test directory to tests and install gherkin globally but still no luck. Here are the full exception details

{code}
gherkin-testcafe chrome tests//*.ts tests//*.feature
ERROR Cannot prepare tests due to an error.

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received type undefined
at getDefinitionLineAndUri (/Users/yogi/playspace/testcafe-cucumber/node_modules/cucumber/lib/support_code_library_builder/build_helpers.js:184:27)
at buildTestCaseHookDefinition (/Users/yogi/playspace/testcafe-cucumber/node_modules/cucumber/lib/support_code_library_builder/build_helpers.js:53:7)
at Object.Before (/Users/yogi/playspace/testcafe-cucumber/node_modules/cucumber/lib/support_code_library_builder/index.js:62:77)
at Object. (/Users/yogi/playspace/testcafe-cucumber/tests/steps/google.ts:8:1)
at Function._execAsModule (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:50:13)
at TypeScriptTestFileCompiler._runCompiledCode (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:150:42)
at TypeScriptTestFileCompiler.execute (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:174:21)
at testFiles.forEach (/usr/local/lib/node_modules/gherkin-testcafe/src/compiler.js:154:26)
at compilerResult.externalCompilers.map (/usr/local/lib/node_modules/gherkin-testcafe/src/compiler.js:153:17)
{code}

Feature file and step files attached from the project (both are copied from examples)
/Users/yogi/playspace/testcafe-cucumber/tests/specs/google.feature
/Users/yogi/playspace/testcafe-cucumber/tests/steps/google.ts

Thanks
Yogi