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

The from argument must be of type string. Recieved Undefined #34

Closed
csurfleet opened this issue Apr 1, 2021 · 5 comments
Closed

The from argument must be of type string. Recieved Undefined #34

csurfleet opened this issue Apr 1, 2021 · 5 comments

Comments

@csurfleet
Copy link

csurfleet commented Apr 1, 2021

I've been really struggling with this one to get things setup, whenever I try to run a test I get this error. The internet suggests that it is due to cucumber being installed multiple times but I've confirmed that it isn't installed elsewhere on the computer, and all my config looks correct. This is my package.json

{
  "name": "mytestspecification",
  "version": "1.0.0",
  "description": "",
  "main": "mytest.js",
  "scripts": {
    "test": "gherkin-testcafe chrome mytest.js mytest.feature"
  },
  "author": "Chris Surfleet",
  "license": "ISC",
  "dependencies": {
    "@cucumber/cucumber": "^7.0.0",
    "@cucumber/cucumber-expressions": "^12.0.0",
    "gherkin-testcafe": "^5.0.0",
    "testcafe": "^1.13.0"
  }
}

This is my feature file:

Feature: Test Prototyping

    Scenario: Update Respitory Support
        Given I am completing the news form
        When I set Respitory Support to Yes
        Then the number thingy on the right shows 2

and my js file:

const { Given, When, Then } = require(process.cwd() + '/node_modules/@cucumber/cucumber');
// Also tried "from '@cucumber/cucumber';"

Given('I am completing the news form', async t => {
    await t.navigateTo('https://google.com');
});

When('I set Respitory Support to Yes', async t => {
    // Do nuthin
});

Then('the number thingy on the right shows 2', async t => {
    // Do nuthin
});

I get this error:
image

I'm not sure what else I can do here as I can't really simplify it any further

@thelazurite-cell
Copy link

Hello @csurfleet,
I wasn't able to reproduce your error exactly, but when I created a new project following your steps I got the following error.


> [email protected] test C:\Code\TestCafe\reprod
> gherkin-testcafe chrome mytest.js mytest.feature

ERROR TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at GherkinTestcafeCompiler.getTests (C:\Code\TestCafe\reprod\node_modules\gh
erkin-testcafe\src\compiler.js:201:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I was able to work around this by creating a folder called 'tests' and placing the feature and js files within that. I also updated the test command to:

"test": "gherkin-testcafe chrome tests/**/*.js tests/**/*.feature"

Can you try this? I have also attached the example project I created to this comment. :-)

reprod.zip

@Arthy000
Copy link
Owner

Arthy000 commented Apr 6, 2021

Hello @csurfleet

Sorry I didn't answer sooner (thanks a lot @thelazurite-cell btw 😊 ).

As you said, this error is often due to an issue in dependencies/organization of the project (#31 recently)

Are you completely certain that Cucumber is not installed globally? (regardless of the version)
Also, are your tests located inside your project? (looks like having your tests out of your project can cause issues => kiwigrid/gherkin-testcafe#45 I was able to reproduce that behavior and I was investigating it before I took tome time off)

@csurfleet
Copy link
Author

Hey all, I found that it was due to a file path! My code was under C:\Source, but cucumber was lower-casing the S, and then complaining that the path with the upper case S didn't match the path with the lower case s, and therefore it was installed in multiple places.

I found it by just installing cucumber directly to another test project - I got a more helpful error, then moved the original project to a lower case file location and all is now well.

Thanks for all the help!

@Arthy000 Arthy000 closed this as completed Apr 6, 2021
@kel666
Copy link

kel666 commented May 30, 2022

Hi
I'm experiencing the same exact issue, which is strange since my deps should be correct:

{
  // ....
  "dependencies": {
    "@ant-design/icons": "^4.6.2",
    "@craco/craco": "^6.4.3",
    "@microsoft/signalr": "^6.0.4",
    "@reduxjs/toolkit": "^1.8.1",
    "@types/jest": "^26.0.20",
    "@types/lodash": "^4.14.168",
    "@types/lz-string": "^1.3.34",
    "@types/mousetrap": "^1.6.5",
    "@types/node": "^12.20.1",
    "@types/react": "^17.0.43",
    "@types/react-dom": "^17.0.14",
    "@types/react-redux": "^7.1.24",
    "@types/react-router-dom": "^5.3.3",
    "@types/redux-logger": "^3.0.8",
    "@types/redux-mock-store": "^1.0.2",
    "@types/uuid": "^8.3.4",
    "antd": "^4.20.5",
    "antd-mask-input": "^2.0.7",
    "clsx": "^1.1.1",
    "core-js": "^3.8.3",
    "craco-antd": "^2.0.0",
    "exceljs": "^4.2.1",
    "file-saver": "^2.0.5",
    "html-to-image": "^1.9.0",
    "i18next": "^19.8.7",
    "lz-string": "^1.4.4",
    "moment": "^2.29.3",
    "moment-business": "^3.0.1",
    "mousetrap": "^1.6.5",
    "oidc-client": "^1.11.4",
    "react": "^18.1.0",
    "react-app-polyfill": "^2.0.0",
    "react-device-detect": "^1.17.0",
    "react-dom": "^18.1.0",
    "react-i18next": "^11.8.6",
    "react-number-format": "^4.4.4",
    "react-redux": "^8.0.2",
    "react-router-dom": "^6.0.0",
    "react-scripts": "^5.0.1",
    "react-tiny-fab": "^4.0.2",
    "redux": "^4.1.2",
    "redux-logger": "^3.0.6",
    "redux-oidc": "^4.0.0-beta1",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "ts-polyfill": "^3.8.2",
    "typescript": "^4.1.5",
    "uuid": "^8.3.2",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
// ...
  },
  "jest": {
    "snapshotSerializers": [
      "jest-serializer-html"
    ]
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "devDependencies": {
    "@cucumber/cucumber": "^7.3.1",
    "@cucumber/cucumber-expressions": "^12.1.2",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.2.0",
    "@testing-library/user-event": "^14.2.0",
    "@types/file-saver": "^2.0.2",
    "@types/moment-business": "^0.1.4",
    "eol-converter-cli": "^1.0.8",
    "eslint": "^7.20.0",
    "eslint-config-prettier": "^7.2.0",
    "eslint-plugin-prettier": "^3.3.1",
    "fetch-mock": "^9.11.0",
    "gherkin-testcafe": "^5.3.0",
    "glob": "^7.1.6",
    "jest-serializer-html": "^7.0.0",
    "prettier": "2.2.1",
    "redux-mock-store": "^1.5.4",
    "serve": "^11.3.2",
    "swagger-typescript-api": "^4.4.0",
    "testcafe": "^1.19.0",
    "testcafe-browser-provider-selenium": "^1.2.0"
  }
}

My only global packkage installed is yarn.
Any idea of what it could be?

Tnx a lot
Fabio

@Arthy000
Copy link
Owner

Hi @kel666

Could you try to downgrade TestCafe to 1.18.6?
I haven't tried version 1.19.0 as it was only released 4 days ago.

It might not be the reason you get this issue though, so if using TC 1.18.6 is not possible or doesn't solve the issue, don't hesitate to open a new issue :)

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

4 participants