cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.51k stars 3.2k forks source link

Cannot run Cucumber feature file with Cypress. Error seen. #9043

Closed Asprao78 closed 4 years ago

Asprao78 commented 4 years ago

I installed cypress-cucumber-preprocessor aiming to run some Cucumber feature File tests on the Cypress RWA App. After following the instructions and installing the necessary files, when I run the Cypress feature file in the Runner, I see the error below:

image

I'm not sure where the error lies. I thought it would be an error with some dependencies and installed Webpack and @cypress/webpack-preprocessor, and yet I see the same error.

I tried setting the option nonGlobalStepDefinitions to false (set to true earlier), but still see the same issue. I'm pretty sure it's not an issue with my Feature File.

Here is the content of my cypress.json file:

{
  "baseUrl": "http://localhost:3000",
  "projectId": "7s5okt",
  "integrationFolder": "cypress/tests",
  "viewportHeight": 1000,
  "viewportWidth": 1280,
  "firefoxGcInterval": null,
  "retries": {
    "runMode": 2,
    "openMode": 1
  },
  "env": {
    "apiUrl": "http://localhost:3001",
    "mobileViewportWidthBreakpoint": 414,
    "coverage": false,
    "codeCoverage": {
      "url": "http://localhost:3001/__coverage__"
    }
  },
  "reporter":"cypress-multi-reporters",
  "reporterOptions":{
    "reporterEnabled":"mochawesome",
    "mochaawesomeReporterOptions":{
      "reportDir":"cypress/reports/mocha",
      "quite":true,
      "overWrite":true,
      "html":false,
      "json":true
    }
  },
  "testFiles":"**/*.feature"
}

Can anyone tell me where I am going wrong.

Below is the content of my package.json file:

{
  "name": "cypress-realworld-app",
  "version": "1.0.0",
  "description": "A payment application to demonstrate **real-world** usage of Cypress testing methods, patterns, and workflows. For a full reference of our documentation, go to https://docs.cypress.io",
  "repository": {
    "type": "git",
    "url": "https://github.com/cypress-io/cypress-realworld-app.git"
  },
  "author": "Cypress DX Team",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/cypress-io/cypress-realworld-app/issues"
  },
  "engines": {
    "node": ">=12"
  },
  "dependencies": {
    "@babel/cli": "7.11.6",
    "@babel/core": "7.11.6",
    "@babel/preset-env": "7.11.5",
    "@material-ui/core": "4.11.0",
    "@material-ui/icons": "4.9.1",
    "@material-ui/lab": "4.0.0-alpha.56",
    "@percy/cypress": "2.3.2",
    "@types/bcryptjs": "2.4.2",
    "@types/bluebird": "3.5.32",
    "@types/connect-flash": "0.0.35",
    "@types/cors": "2.8.8",
    "@types/dinero.js": "1.6.5",
    "@types/express": "4.17.2",
    "@types/express-paginate": "1.0.0",
    "@types/express-serve-static-core": "4.17.2",
    "@types/express-session": "1.17.0",
    "@types/faker": "5.1.2",
    "@types/jest": "26.0.14",
    "@types/json-server": "0.14.2",
    "@types/lodash": "4.14.162",
    "@types/lowdb": "1.0.9",
    "@types/morgan": "1.9.1",
    "@types/node": "14.11.8",
    "@cypress/webpack-preprocessor": "^4.0.3",
    "@types/passport": "1.0.4",
    "@types/react": "16.9.52",
    "@types/react-dom": "16.9.8",
    "@types/react-infinite-calendar": "2.3.5",
    "@types/react-router": "5.1.8",
    "@types/react-router-dom": "5.1.6",
    "@types/react-virtualized": "9.21.10",
    "@types/shortid": "0.0.29",
    "@types/uuid": "8.3.0",
    "@types/validator": "13.1.0",
    "@types/webpack-env": "1.15.3",
    "@types/yup": "0.29.8",
    "@xstate/react": "0.8.1",
    "axios": "0.20.0",
    "bcryptjs": "2.4.3",
    "concurrently": "5.3.0",
    "cors": "2.8.5",
    "cross-env": "7.0.2",
    "date-fns": "2.16.1",
    "dinero.js": "1.8.1",
    "dotenv": "8.2.0",
    "express-paginate": "1.0.2",
    "express-session": "1.17.1",
    "express-validator": "6.6.1",
    "faker": "5.1.0",
    "formik": "2.2.0",
    "fuse.js": "6.4.1",
    "husky": "4.3.0",
    "json": "10.0.0",
    "lowdb": "1.0.0",
    "mocha": "^8.1.3",
    "morgan": "1.10.0",
    "ncp": "2.0.0",
    "nodemon": "2.0.4",
    "passport": "0.4.1",
    "passport-local": "1.0.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-infinite-calendar": "2.3.1",
    "react-number-format": "4.4.1",
    "react-router": "5.2.0",
    "react-router-dom": "5.2.0",
    "react-scripts": "3.4.0",
    "react-virtualized": "9.22.2",
    "shortid": "2.2.15",
    "ts-node": "9.0.0",
    "typescript": "4.0.3",
    "uuid": "8.3.1",
    "webpack":"^4.18.1",
    "xstate": "4.13.0",
    "yup": "0.29.3"
  },
  "devDependencies": {
    "@cypress/code-coverage": "3.8.1",
    "@cypress/instrument-cra": "1.3.2",
    "@types/connect-history-api-fallback": "1.3.3",
    "@types/http-proxy-middleware": "0.19.3",
    "babel-loader": "8.0.6",
    "cypress": "^5.4.0",
    "cypress-cucumber-preprocessor": "^3.0.0",
    "cypress-multi-reporters": "^1.4.0",
    "eslint": "^6.6.0",
    "eslint-config-prettier": "6.12.0",
    "eslint-plugin-cypress": "2.11.2",
    "eslint-plugin-prettier": "3.1.4",
    "istanbul-lib-coverage": "3.0.0",
    "mochawesome": "^6.1.1",
    "mochawesome-merge": "^4.2.0",
    "mochawesome-report-generator": "^5.1.0",
    "nyc": "15.1.0",
    "prettier": "2.1.2",
    "start-server-and-test": "1.11.5"
  },
  "resolutions": {
    "@babel/compat-data": "7.9.0",
    "@types/express": "4.17.2",
    "@types/express-serve-static-core": "4.17.2"
  },
  "scripts": {
    "dev": "cross-env NODE_ENV=development concurrently yarn:start:react yarn:start:api:watch",
    "start": "cross-env NODE_ENV=development concurrently yarn:start:react yarn:start:api",
    "start:ci": "cross-env NODE_ENV=test concurrently yarn:start:react yarn:start:api",
    "start:react": "react-scripts -r @cypress/instrument-cra start",
    "start:empty": "cross-env NODE_ENV=development EMPTY_SEED=true concurrently yarn:start:react yarn:start:api:watch",
    "list:dev:users": "cat data/database.json | json -a users | json -a id username",
    "types": "tsc --noEmit",
    "cypress:open": "cypress open",
    "cypress:open:mobile": "cypress open --config viewportWidth=375,viewportHeight=667",
    "cypress:run": "cypress run",
    "cypress:runspec":"cypress run --spec cypress/tests/sample_ui/**/*",
    "cypress:run:mobile": "cypress run --config viewportWidth=375,viewportHeight=667",
    "test": "yarn cypress:open",
    "test:headless": "yarn cypress:run",
    "test:api": "yarn cypress:run --spec 'integration/api/*'",
    "test:unit": "react-scripts test --runInBand",
    "test:unit:ci": "react-scripts test --watch false --runInBand",
    "start:api": "yarn tsnode --files backend/app.ts",
    "start:api:watch": "nodemon --exec yarn tsnode --watch 'backend' backend/app.ts",
    "start:react:proxy-server": "yarn tsnode scripts/testServer.ts",
    "prettier": "prettier --write '**/**.{ts,js,tsx}' '*.{json,md,yml}'",
    "tsnode": "nyc --silent ts-node -P tsconfig.tsnode.json",
    "tsnode:not-instrumented": "ts-node -P tsconfig.tsnode.json",
    "db:seed": "yarn tsnode scripts/generateSeedData",
    "db:seed:dev": "ncp ./data/database-seed.json ./data/database.json",
    "db:seed:empty": "ncp ./data/empty-seed.json ./data/database.json",
    "postdb:seed": "yarn db:seed:dev",
    "prestart": "yarn db:seed:dev",
    "predev": "yarn db:seed:dev",
    "prestart:empty": "yarn db:seed:empty",
    "prebuild": "yarn types",
    "build": "react-scripts build",
    "eject": "react-scripts eject",
    "codesandbox:start:api": "yarn tsnode:not-instrumented --files backend/app.ts",
    "codesandbox:start": "NODE_ENV=development TSC_COMPILE_ON_ERROR=true concurrently \"react-scripts start\" yarn:start:api:codesandbox",
    "clean:reports":"rm -r cypress/reports",
    "mkdir:reports":"mkdir cypress\\reports",
    "mksubdir:reports":"mkdir cypress\\reports\\mochareports",
    "pretestprep":"yarn clean:reports && yarn mkdir:reports && yarn mksubdir:reports",
    "combine-reports":"mochawesome-merge mochawesome-report/*.json > cypress/reports/mochareports/report.json",
    "generate-report":"marge cypress/reports/mochareports/report.json -f report -o cypress/reports/mochareports",
    "posttest":"yarn combine-reports && yarn generate-report"

  },
  "eslintConfig": {
    "env": {
      "cypress/globals": true
    },
    "extends": [
      "react-app",
      "plugin:prettier/recommended",
      "plugin:cypress/recommended"
    ],
    "plugins": [
      "cypress",
      "prettier"
    ],
    "rules": {
      "no-unused-expressions": 0
    }
  },
  "jest": {
    "watchPathIgnorePatterns": [
      "<rootDir>/data/database.json",
      "<rootDir>/data/database-seed.json"
    ]
  },
  "husky": {
    "hooks": {
      "pre-push": "yarn types"
    }
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "percy": {
    "version": 1,
    "snapshot": {
      "widths": [
        1280
      ]
    }
  },
  "nyc": {
    "exclude": [
      "src/models/*.ts"
    ],
    "reporter": [
      "html",
      "json"
    ]
  },
  "cypress-cucumber-preprocessor":{
    "nonGlobalStepDefinitions":false,
    "cucumberJson":{
      "generate":true,
      "outputFolder":"cypress/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }
  }
}
jennifer-shehane commented 4 years ago

You can take a look at cypress-cucumber-preprocessor's instructions on how to run with Webpack. https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#with-webpack They also have an example with TypeScript and Webpack: https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example

Issues in this repo are reserved for potential bugs or feature requests so that our team can fully focus on improving the product. This issue will be closed since it appears to be neither a bug nor a feature request.

We suggest asking questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.