Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Invalid argument type #45

Open
Mohamed-Haaziq opened this issue Jul 19, 2019 · 6 comments
Open

Invalid argument type #45

Mohamed-Haaziq opened this issue Jul 19, 2019 · 6 comments

Comments

@Mohamed-Haaziq
Copy link

Mohamed-Haaziq commented Jul 19, 2019

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)

@Lukas-Kullmann
Copy link
Contributor

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

@yauhenbarysik
Copy link

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.

@Lukas-Kullmann
Copy link
Contributor

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

@microhod
Copy link

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?

@Lukas-Kullmann
Copy link
Contributor

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.

@yrnayudu
Copy link

yrnayudu commented Oct 4, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants