Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gherkin-testcafe is running in to TypeError #31

Closed
raj-balaebail opened this issue Mar 23, 2021 · 14 comments
Closed

gherkin-testcafe is running in to TypeError #31

raj-balaebail opened this issue Mar 23, 2021 · 14 comments

Comments

@raj-balaebail
Copy link

Trying to get the cucumber and testcafe integration going.

ERROR Cannot prepare tests due to an error.

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
    at Object.getDefinitionLineAndUri (/Users/rajbalaebail/node_modules/@cucumber/cucumber/src/support_code_library_builder/build_helpers.ts:21:18)
    at SupportCodeLibraryBuilder.defineStep (/Users/rajbalaebail/node_modules/@cucumber/cucumber/src/support_code_library_builder/index.ts:133:27)
    at Object.<anonymous> (/Users/rajbalaebail/amount-repos/CucumberPOC/features/step_definitions/CF-1951.js:7:1)
    at /Users/rajbalaebail/gherkin-testcafe/src/compiler.js:243:26
    at /Users/rajbalaebail/gherkin-testcafe/src/compiler.js:242:17
    at GherkinTestcafeCompiler._loadStepDefinitions (/Users/rajbalaebail/gherkin-testcafe/src/compiler.js:247:5)
    at GherkinTestcafeCompiler.getTests (/Users/rajbalaebail/gherkin-testcafe/src/compiler.js:143:5)
@Arthy000
Copy link
Owner

Hello @raj-balaebail,

What version of the package are you using?
What version of TestCafe did you install?
What version of Cucumber did you install?

The error you describe is typically what you get when some of the dependencies are not met.

@raj-balaebail
Copy link
Author

raj-balaebail commented Mar 23, 2021

I was following the instructions in the main readme. I installed all peer dependencies that was mentioned as missing.

rajbalaebail@Rajs-MacBook-Pro ~ % npm list | grep gherkin-testcafe    
├─┬ [email protected] -> /Users/rajbalaebail/gherkin-testcafe
rajbalaebail@Rajs-MacBook-Pro ~ % npm list | grep testcafe            
├─┬ [email protected] -> /Users/rajbalaebail/gherkin-testcafe
└─┬ [email protected]
  ├─┬ [email protected]
  ├─┬ [email protected]
  ├─┬ [email protected]
  │ └── [email protected] deduped
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
rajbalaebail@Rajs-MacBook-Pro ~ % npm list | grep @cucumber/cucumber
├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]

@raj-balaebail
Copy link
Author

PS: I can do a reinstall and clean install of all the repos if that is preferable.

@Arthy000
Copy link
Owner

Hello again,

I think I see the issue, the documentation you followed is about a version that hasn't been published yet (that's completely my fault, I set develop as the main branch but I publish/release master, I corrected that)

However the only way you got the warning you did is if you also have cucumber installed (as opposed to @cucumber/cucumber) in a version that is higher than 5.1.0

I'm releasing the new version now so you should just have tu upgrade gherkin-testcafe in a few minutes. From then it will be using @cucumber/cucumber and ignore whatever version of cucumber you have.

@Arthy000
Copy link
Owner

Bumped the version to 5.0.0 as updating cucumber was a breaking change. Can you upgrade and let me know if your issue is solved?

@raj-balaebail
Copy link
Author

I still run in to the issue and I don't seem to have cucumber installed.

rajbalaebail@Rajs-MacBook-Pro ~ % npm list | grep gherkin-testcafe 
├─┬ [email protected] -> /Users/rajbalaebail/gherkin-testcafe
rajbalaebail@Rajs-MacBook-Pro ~ % gherkin-testcafe firefox amount-repos/CucumberPOC/**/*.js amount-repos/CucumberPOC/**/*.feature 
ERROR Cannot prepare tests due to an error.

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
    at Object.getDefinitionLineAndUri (/Users/rajbalaebail/node_modules/@cucumber/cucumber/src/support_code_library_builder/build_helpers.ts:21:18)
    at SupportCodeLibraryBuilder.defineStep (/Users/rajbalaebail/node_modules/@cucumber/cucumber/src/support_code_library_builder/index.ts:133:27)
    at Object.<anonymous> (/Users/rajbalaebail/amount-repos/CucumberPOC/test/features/step_definitions/CF-1951.js:7:1)
    at /Users/rajbalaebail/gherkin-testcafe/src/compiler.js:243:26
    at /Users/rajbalaebail/gherkin-testcafe/src/compiler.js:242:17
    at GherkinTestcafeCompiler._loadStepDefinitions (/Users/rajbalaebail/gherkin-testcafe/src/compiler.js:247:5)
    at GherkinTestcafeCompiler.getTests (/Users/rajbalaebail/gherkin-testcafe/src/compiler.js:143:5)

Type "testcafe -h" for help.
rajbalaebail@Rajs-MacBook-Pro ~ % npm list | grep cucumber        
├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├── @cucumber/[email protected] deduped
│ ├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├── @cucumber/[email protected] deduped
│ ├─┬ @cucumber/[email protected]
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ ├── @cucumber/[email protected] deduped
│ │ ├── @cucumber/[email protected] deduped
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ ├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├── @cucumber/[email protected] deduped
│ ├── @cucumber/[email protected]
├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ ├─┬ @cucumber/[email protected]
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├─┬ @cucumber/[email protected]
│ │ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├─┬ @cucumber/[email protected]
│ │ │ │ ├── @cucumber/[email protected] deduped
│ │ │ │ ├── @cucumber/[email protected] deduped
│ │ │ │ ├── @cucumber/[email protected] deduped
│ │ │ │ ├── @cucumber/[email protected] deduped
│ │ ├─┬ @cucumber/[email protected]
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ ├── @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│   ├─┬ [email protected]

@Arthy000
Copy link
Owner

I created a project from scratch on my Mac, no issue :(

Your dependency tree seems a bit messed up compared to mine.

~/gherkin-testcafe-tester $ npm list | grep cucumber
├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├── @cucumber/[email protected] deduped
│ ├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├── @cucumber/[email protected] deduped
│ ├─┬ @cucumber/[email protected]
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ ├── @cucumber/[email protected] deduped
│ │ ├── @cucumber/[email protected] deduped
│ │ ├─┬ @cucumber/[email protected]
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ │ │ ├── @cucumber/[email protected] deduped
│ ├─┬ @cucumber/[email protected]
│ ├─┬ @cucumber/[email protected]
│ │ ├── @cucumber/[email protected] deduped
│ ├── @cucumber/[email protected]
├─┬ @cucumber/[email protected]
│ ├── @cucumber/[email protected] deduped
│ ├── @cucumber/[email protected] deduped
│   ├─┬ [email protected]

First thing to try is to rebuild your node_modules from scratch.

If that doesn't work, may I see your package.json?

@Arthy000
Copy link
Owner

AHA !
Found something, are your features/steps files located in a folder outside of your project?

kiwigrid/gherkin-testcafe#45

@raj-balaebail
Copy link
Author

    "@cucumber/cucumber": "^7.0.0",
    "@cucumber/cucumber-expressions": "^12.0.0",
    "@types/react": "^17.0.3",
    "gherkin-testcafe": "file:gherkin-testcafe",
    "react-markdown": "^5.0.3",
    "testcafe": "^1.13.0"
  },
  "devDependencies": {}
}

@raj-balaebail
Copy link
Author

My package.json is in my home directory and the tests are nested three directories within my home directory.

@Arthy000
Copy link
Owner

When you say home directory, do you mean the home directory of your project or the home directory of your user?

@raj-balaebail
Copy link
Author

User home directory

@raj-balaebail
Copy link
Author

I seem to have gotten past this error after uninstalling all copies of cucumber, gherkin, gherkin-testcafe and reinstalling it. I am running in to other errors in the code though that I will look at. Thanks for the help !!

@Arthy000
Copy link
Owner

You're welcome :)
If I were you I'd create a project directory and use local (installed without -g) versions of the packages. It will prevent interactions between packages that were installed for other reasons.

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

No branches or pull requests

2 participants