Repository: TheBrainFamily/cypress-cucumber-preprocessor (js)

Issue:
--config-file param not working with this plugin
Hey there,

I figured out that the --config-file parameter isn't working anymore with this plugin. The following exception shows that this plugin tries to determine the location of the step definitions and fails because nodejs's path.join method expected a String rather than a Boolean.

My execution command: `./node_modules/.bin/cypress run --config-file "config/cypress/cypress.json"`

```
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean
    at validateString (internal/validators.js:105:11)
    at Object.resolve (path.js:978:7)
    at module.exports (/var/www/thunder/web-order/node_modules/cypress-cucumber-preprocessor/lib/stepDefinitionPath.js:11:14)
    at getStepDefinitionsPaths (/var/www/thunder/web-order/node_modules/cypress-cucumber-preprocessor/lib/getStepDefinitionsPaths.js:15:38)
    at module.exports (/var/www/thunder/web-order/node_modules/cypress-cucumber-preprocessor/lib/loader.js:25:36)
    at Stream.end (/var/www/thunder/web-order/node_modules/cypress-cucumber-preprocessor/lib/index.js:25:18)
    at _end (./node_modules/through/index.js:65:9)
    at Stream.stream.end (./node_modules/through/index.js:74:5)
    at DestroyableTransform.onend (./node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:282:20)
    at DestroyableTransform.emit (events.js:199:15)
    at endReadableNT (./node_modules/readable-stream/lib/_stream_readable.js:1010:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)
```

I looked into the file cypressExecutionInstance.js and checked the result of ps-node's lookup function. It returns the the arguments in the wrong order and this leads to wrong value assignment and the --config-file argument is considered as flag (boolean).

```
[ { pid: '3714',
    command: '/home/fragsalat/.cache/Cypress/3.6.1/Cypress/Cypress',
    arguments:
     [ '--run-project',
       '--config-file',
       '--cwd',
       '--no-sandbox',
       '/path/to/app',
       'config/cypress/cypress.json',
       '/path/to/app' ],
    ppid: '3544' } ]
```

This results in the following config
```
{ _:
   [ '/path/to/project',
     'config/cypress/cypress.json',
     '/path/to/project' ],
  'run-project': true,
  'config-file': true,
  cwd: true,
  sandbox: false }
```

I could open the bug also in ps-node I guess but may you find a better alternative to get the process arguments.
Thanks upfront for looking into this and for your work on this plugin :)

Pull request:
fix(stepdefinitionpath): do not rely on cypress configuration for det…
…ermining the stepDefinitionPath

Relying on any parts of the cypress configuration has been problematic since the beginning, it was
time to use only the configuration that we own. This is a breaking change but it should be
relatively easy to adjust to it. And for people using defaults - nothing changes. Should improve
performance especially on Windows.

BREAKING CHANGE: You need to configure the stepDefinitions if you use the nonGlobalStepDefinitions
option.

re #295 , fix #283

Patch:
diff --git a/README.md b/README.md
index 3d78abf..b485436 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Option | Default value | Description
 ------------ | ------------- | -------------
 commonPath | `cypress/integration/common` when `nonGlobalStepDefinitions` is true <br> `cypress/support/step_definitions` when `nonGlobalStepDefinitions` is false | Define the path to a folder containing all common step definitions of your tests
 nonGlobalStepDefinitions | false | If true use the Cypress Cucumber Preprocessor Style pattern for placing step definitions files. If false, we will use the "oldschool" (everything is global) Cucumber style
-step_definitions | `cypress/support/step_definitions` | Path to the folder containing our step definitions
+stepDefinitions | `cypress/integration` when `nonGlobalStepDefinitions` is true <br> `cypress/support/step_definitions` when `nonGlobalStepDefinitions` is false | Path to the folder containing our step definitions.
 
 ## How to organize the tests
 
diff --git a/lib/cypressExecutionInstance.js b/lib/cypressExecutionInstance.js
index 3f411a4..e69de29 100644
--- a/lib/cypressExecutionInstance.js
+++ b/lib/cypressExecutionInstance.js
@@ -1,31 +0,0 @@
-const ps = require("ps-node");
-const minimist = require("minimist");
-
-let cypressExecArgs;
-const lookupCypressQuery = {
-  command: "cypress",
-  arguments: "--config-file"
-};
-
-module.exports = {
-  load: async () =>
-    new Promise(resolve => {
-      ps.lookup(lookupCypressQuery, (err, resultList) => {
-        if (err) {
-          resolve();
-        }
-        cypressExecArgs = resultList
-          .filter(process => process && process.arguments.length)
-          .map(process => minimist(process.arguments))
-          .reduce(
-            (processArgs, finalProcessArgs) => ({
-              ...finalProcessArgs,
-              ...processArgs
-            }),
-            {}
-          );
-        resolve();
-      });
-    }),
-  getArguments: () => cypressExecArgs
-};
diff --git a/lib/index.js b/lib/index.js
index 93b8ca6..76ffb4e 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -7,7 +7,6 @@ const chokidar = require("chokidar");
 const compile = require("./loader.js");
 const compileFeatures = require("./featuresLoader.js");
 const stepDefinitionPath = require("./stepDefinitionPath.js");
-const cypressExecutionInstance = require("./cypressExecutionInstance");
 
 const transform = file => {
   let data = "";
@@ -42,8 +41,6 @@ const preprocessor = (options = browserify.defaultOptions) => async file => {
   if (options.browserifyOptions.transform.indexOf(transform) === -1) {
     options.browserifyOptions.transform.unshift(transform);
   }
-  // load arguments from running Cypress instance
-  await cypressExecutionInstance.load();
 
   if (file.shouldWatch) {
     if (watcher) {
diff --git a/lib/stepDefinitionPath.js b/lib/stepDefinitionPath.js
index d855882..ffa9382 100644
--- a/lib/stepDefinitionPath.js
+++ b/lib/stepDefinitionPath.js
@@ -1,44 +1,35 @@
-const fs = require("fs");
 const path = require("path");
 const cosmiconfig = require("cosmiconfig");
-const cypressExecutionInstance = require("./cypressExecutionInstance");
+const fs = require("fs");
 
 module.exports = () => {
   const appRoot = process.cwd();
-  const cypressExecutionArguments = cypressExecutionInstance.getArguments();
-  const cypressConfigPath =
-    cypressExecutionArguments && cypressExecutionArguments["config-file"]
-      ? path.resolve(appRoot, cypressExecutionArguments["config-file"])
-      : `${appRoot}/cypress.json`;
-  const cypressOptions = JSON.parse(
-    fs.readFileSync(cypressConfigPath, "utf-8")
-  );
 
   const explorer = cosmiconfig("cypress-cucumber-preprocessor", { sync: true });
   const loaded = explorer.load();
   if (loaded && loaded.config) {
-    const { config } = loaded;
-    if (config.nonGlobalStepDefinitions && config.step_definitions) {
-      throw new Error(
-        "Error! You can't have both step_definitions folder and nonGlobalStepDefinitions setup in cypress-cucumber-preprocessor configuration"
-      );
-    }
+    const { config, filepath } = loaded;
+
+    // left for backward compability, but we need the consistency with other configuration options
+    const confStepDefinitions = config.step_definitions
+      ? config.step_definitions
+      : config.stepDefinitions;
+
     if (config.nonGlobalStepDefinitions) {
-      return path.resolve(
-        appRoot,
-        cypressOptions.integrationFolder || "cypress/integration"
-      );
+      const relativePath = confStepDefinitions || "cypress/integration";
+      const stepsPath = path.resolve(appRoot, relativePath);
+
+      if (!fs.existsSync(stepsPath)) {
+        throw new Error(
+          `We've tried to resolve your step definitions at ${relativePath}, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Currently your configuration is in: ${filepath}. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.`
+        );
+      }
+      return stepsPath;
     }
-    if (config.step_definitions) {
-      return path.resolve(appRoot, config.step_definitions);
+    if (confStepDefinitions) {
+      return path.resolve(appRoot, confStepDefinitions);
     }
   }
 
-  // XXX Deprecated, left here for backward compability
-
-  if (cypressOptions && cypressOptions.fileServerFolder) {
-    return `${cypressOptions.fileServerFolder}/support/step_definitions`;
-  }
-
   return `${appRoot}/cypress/support/step_definitions`;
 };
diff --git a/package-lock.json b/package-lock.json
index 6e555c4..5d65e76 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2737,7 +2737,7 @@
         },
         "globby": {
           "version": "8.0.1",
-          "resolved": "https://registry.npmjs.org/globby/-/globby-8.0.1.tgz",
+          "resolved": "http://registry.npmjs.org/globby/-/globby-8.0.1.tgz",
           "integrity": "sha512-oMrYrJERnKBLXNLVTqhm3vPEdJ/b2ZE28xN4YARiix1NOIOBPEpOUnm844K1iu/BkphCaf2WNFwMszv8Soi1pw==",
           "dev": true,
           "requires": {
@@ -3149,7 +3149,6 @@
       "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
       "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
       "dev": true,
-      "optional": true,
       "requires": {
         "kind-of": "^3.0.2",
         "longest": "^1.0.1",
@@ -3998,7 +3997,7 @@
       "dependencies": {
         "callsites": {
           "version": "2.0.0",
-          "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
+          "resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
           "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=",
           "dev": true
         }
@@ -4975,11 +4974,6 @@
         "typedarray": "^0.0.6"
       }
     },
-    "connected-domain": {
-      "version": "1.0.0",
-      "resolved": "https://registry.npmjs.org/connected-domain/-/connected-domain-1.0.0.tgz",
-      "integrity": "sha1-v+dyOMdL5FOnnwy2BY3utPI1jpM="
-    },
     "console-browserify": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
@@ -5743,7 +5737,7 @@
       "dependencies": {
         "minimist": {
           "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
         }
       }
@@ -7565,8 +7559,7 @@
         "ansi-regex": {
           "version": "2.1.1",
           "resolved": false,
-          "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
-          "optional": true
+          "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
         },
         "aproba": {
           "version": "1.2.0",
@@ -7587,14 +7580,12 @@
         "balanced-match": {
           "version": "1.0.0",
           "resolved": false,
-          "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
-          "optional": true
+          "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
         },
         "brace-expansion": {
           "version": "1.1.11",
           "resolved": false,
           "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
-          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -7609,20 +7600,17 @@
         "code-point-at": {
           "version": "1.1.0",
           "resolved": false,
-          "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
-          "optional": true
+          "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
         },
         "concat-map": {
           "version": "0.0.1",
           "resolved": false,
-          "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
-          "optional": true
+          "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
         },
         "console-control-strings": {
           "version": "1.1.0",
           "resolved": false,
-          "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
-          "optional": true
+          "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -7739,8 +7727,7 @@
         "inherits": {
           "version": "2.0.3",
           "resolved": false,
-          "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
-          "optional": true
+          "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
         },
         "ini": {
           "version": "1.3.5",
@@ -7752,7 +7739,6 @@
           "version": "1.0.0",
           "resolved": false,
           "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
-          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -7767,7 +7753,6 @@
           "version": "3.0.4",
           "resolved": false,
           "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
-          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -7775,14 +7760,12 @@
         "minimist": {
           "version": "0.0.8",
           "resolved": false,
-          "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
-          "optional": true
+          "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
         },
         "minipass": {
           "version": "2.2.4",
           "resolved": false,
           "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
-          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.1",
             "yallist": "^3.0.0"
@@ -7801,7 +7784,6 @@
           "version": "0.5.1",
           "resolved": false,
           "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
-          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -7882,8 +7864,7 @@
         "number-is-nan": {
           "version": "1.0.1",
           "resolved": false,
-          "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
-          "optional": true
+          "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
         },
         "object-assign": {
           "version": "4.1.1",
@@ -7895,7 +7876,6 @@
           "version": "1.4.0",
           "resolved": false,
           "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
-          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -7981,8 +7961,7 @@
         "safe-buffer": {
           "version": "5.1.1",
           "resolved": false,
-          "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
-          "optional": true
+          "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
         },
         "safer-buffer": {
           "version": "2.1.2",
@@ -8018,7 +7997,6 @@
           "version": "1.0.2",
           "resolved": false,
           "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
-          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -8038,7 +8016,6 @@
           "version": "3.0.1",
           "resolved": false,
           "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
-          "optional": true,
           "requires": {
             "ansi-regex": "^2.0.0"
           }
@@ -8082,14 +8059,12 @@
         "wrappy": {
           "version": "1.0.2",
           "resolved": false,
-          "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
-          "optional": true
+          "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
         },
         "yallist": {
           "version": "3.0.2",
           "resolved": false,
-          "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
-          "optional": true
+          "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
         }
       }
     },
@@ -10473,8 +10448,7 @@
               "version": "2.1.1",
               "resolved": false,
               "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "aproba": {
               "version": "1.2.0",
@@ -10498,15 +10472,13 @@
               "version": "1.0.0",
               "resolved": false,
               "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "brace-expansion": {
               "version": "1.1.11",
               "resolved": false,
               "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
               "dev": true,
-              "optional": true,
               "requires": {
                 "balanced-match": "^1.0.0",
                 "concat-map": "0.0.1"
@@ -10523,22 +10495,19 @@
               "version": "1.1.0",
               "resolved": false,
               "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "concat-map": {
               "version": "0.0.1",
               "resolved": false,
               "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "console-control-strings": {
               "version": "1.1.0",
               "resolved": false,
               "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "core-util-is": {
               "version": "1.0.2",
@@ -10669,8 +10638,7 @@
               "version": "2.0.3",
               "resolved": false,
               "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "ini": {
               "version": "1.3.5",
@@ -10684,7 +10652,6 @@
               "resolved": false,
               "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
               "dev": true,
-              "optional": true,
               "requires": {
                 "number-is-nan": "^1.0.0"
               }
@@ -10701,7 +10668,6 @@
               "resolved": false,
               "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
               "dev": true,
-              "optional": true,
               "requires": {
                 "brace-expansion": "^1.1.7"
               }
@@ -10710,15 +10676,13 @@
               "version": "0.0.8",
               "resolved": false,
               "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "minipass": {
               "version": "2.3.5",
               "resolved": false,
               "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
               "dev": true,
-              "optional": true,
               "requires": {
                 "safe-buffer": "^5.1.2",
                 "yallist": "^3.0.0"
@@ -10739,7 +10703,6 @@
               "resolved": false,
               "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
               "dev": true,
-              "optional": true,
               "requires": {
                 "minimist": "0.0.8"
               }
@@ -10828,8 +10791,7 @@
               "version": "1.0.1",
               "resolved": false,
               "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "object-assign": {
               "version": "4.1.1",
@@ -10843,7 +10805,6 @@
               "resolved": false,
               "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
               "dev": true,
-              "optional": true,
               "requires": {
                 "wrappy": "1"
               }
@@ -10939,8 +10900,7 @@
               "version": "5.1.2",
               "resolved": false,
               "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "safer-buffer": {
               "version": "2.1.2",
@@ -10982,7 +10942,6 @@
               "resolved": false,
               "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
               "dev": true,
-              "optional": true,
               "requires": {
                 "code-point-at": "^1.0.0",
                 "is-fullwidth-code-point": "^1.0.0",
@@ -11004,7 +10963,6 @@
               "resolved": false,
               "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
               "dev": true,
-              "optional": true,
               "requires": {
                 "ansi-regex": "^2.0.0"
               }
@@ -11053,15 +11011,13 @@
               "version": "1.0.2",
               "resolved": false,
               "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
-              "dev": true,
-              "optional": true
+              "dev": true
             },
             "yallist": {
               "version": "3.0.3",
               "resolved": false,
               "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
-              "dev": true,
-              "optional": true
+              "dev": true
             }
           }
         },
@@ -12261,7 +12217,7 @@
     },
     "json5": {
       "version": "0.5.1",
-      "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
+      "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
       "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=",
       "dev": true
     },
@@ -12791,7 +12747,7 @@
             },
             "chalk": {
               "version": "1.1.3",
-              "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
+              "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
               "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
               "dev": true,
               "requires": {
@@ -13196,8 +13152,7 @@
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
       "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=",
-      "dev": true,
-      "optional": true
+      "dev": true
     },
     "loose-envify": {
       "version": "1.4.0",
@@ -13399,7 +13354,7 @@
         },
         "minimist": {
           "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
           "dev": true
         },
@@ -17400,7 +17355,7 @@
     },
     "onetime": {
       "version": "1.1.0",
-      "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
+      "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
       "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=",
       "dev": true
     },
@@ -17914,14 +17869,6 @@
         "sisteransi": "^1.0.3"
       }
     },
-    "ps-node": {
-      "version": "0.1.6",
-      "resolved": "https://registry.npmjs.org/ps-node/-/ps-node-0.1.6.tgz",
-      "integrity": "sha1-mvZ6mdex0BMuUaUDCZ04qNKs4sM=",
-      "requires": {
-        "table-parser": "^0.1.3"
-      }
-    },
     "pseudomap": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
@@ -18027,7 +17974,7 @@
       "dependencies": {
         "minimist": {
           "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
           "dev": true
         }
@@ -18235,7 +18182,7 @@
       "dependencies": {
         "jsesc": {
           "version": "0.5.0",
-          "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
+          "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
           "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0="
         }
       }
@@ -19107,7 +19054,7 @@
             },
             "get-stream": {
               "version": "3.0.0",
-              "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
+              "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
               "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=",
               "dev": true
             }
@@ -19115,7 +19062,7 @@
         },
         "p-is-promise": {
           "version": "1.1.0",
-          "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz",
+          "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz",
           "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=",
           "dev": true
         },
@@ -19891,7 +19838,7 @@
       "dependencies": {
         "minimist": {
           "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+          "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
           "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
         }
       }
@@ -20019,14 +19966,6 @@
         }
       }
     },
-    "table-parser": {
-      "version": "0.1.3",
-      "resolved": "https://registry.npmjs.org/table-parser/-/table-parser-0.1.3.tgz",
-      "integrity": "sha1-BEHPzhallIFoTCfRtaZ/8VpDx7A=",
-      "requires": {
-        "connected-domain": "^1.0.0"
-      }
-    },
     "test-exclude": {
       "version": "5.2.3",
       "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz",
@@ -20319,7 +20258,7 @@
     },
     "tough-cookie": {
       "version": "2.3.4",
-      "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
+      "resolved": "http://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
       "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
       "dev": true,
       "requires": {
@@ -20775,8 +20714,7 @@
             },
             "ansi-regex": {
               "version": "2.1.1",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "aproba": {
               "version": "1.2.0",
@@ -20794,13 +20732,11 @@
             },
             "balanced-match": {
               "version": "1.0.0",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "brace-expansion": {
               "version": "1.1.11",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "balanced-match": "^1.0.0",
                 "concat-map": "0.0.1"
@@ -20813,18 +20749,15 @@
             },
             "code-point-at": {
               "version": "1.1.0",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "concat-map": {
               "version": "0.0.1",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "console-control-strings": {
               "version": "1.1.0",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "core-util-is": {
               "version": "1.0.2",
@@ -20927,8 +20860,7 @@
             },
             "inherits": {
               "version": "2.0.3",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "ini": {
               "version": "1.3.5",
@@ -20938,7 +20870,6 @@
             "is-fullwidth-code-point": {
               "version": "1.0.0",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "number-is-nan": "^1.0.0"
               }
@@ -20951,20 +20882,17 @@
             "minimatch": {
               "version": "3.0.4",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "brace-expansion": "^1.1.7"
               }
             },
             "minimist": {
               "version": "0.0.8",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "minipass": {
               "version": "2.3.5",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "safe-buffer": "^5.1.2",
                 "yallist": "^3.0.0"
@@ -20981,7 +20909,6 @@
             "mkdirp": {
               "version": "0.5.1",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "minimist": "0.0.8"
               }
@@ -21054,8 +20981,7 @@
             },
             "number-is-nan": {
               "version": "1.0.1",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "object-assign": {
               "version": "4.1.1",
@@ -21065,7 +20991,6 @@
             "once": {
               "version": "1.4.0",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "wrappy": "1"
               }
@@ -21141,8 +21066,7 @@
             },
             "safe-buffer": {
               "version": "5.1.2",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "safer-buffer": {
               "version": "2.1.2",
@@ -21172,7 +21096,6 @@
             "string-width": {
               "version": "1.0.2",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "code-point-at": "^1.0.0",
                 "is-fullwidth-code-point": "^1.0.0",
@@ -21190,7 +21113,6 @@
             "strip-ansi": {
               "version": "3.0.1",
               "bundled": true,
-              "optional": true,
               "requires": {
                 "ansi-regex": "^2.0.0"
               }
@@ -21229,13 +21151,11 @@
             },
             "wrappy": {
               "version": "1.0.2",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             },
             "yallist": {
               "version": "3.0.3",
-              "bundled": true,
-              "optional": true
+              "bundled": true
             }
           }
         },
diff --git a/package.json b/package.json
index 0e77349..c8bd1ec 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,6 @@
     "glob": "^7.1.2",
     "js-string-escape": "^1.0.1",
     "minimist": "^1.2.0",
-    "ps-node": "^0.1.6",
     "through": "^2.3.8"
   },
   "devDependencies": {


Test patch:
diff --git a/lib/stepDefinitionPath.test.js b/lib/stepDefinitionPath.test.js
index 0fcf4fc..f4402a0 100644
--- a/lib/stepDefinitionPath.test.js
+++ b/lib/stepDefinitionPath.test.js
@@ -1,114 +1,121 @@
 const fs = require("fs");
 const cosmiconfig = require("cosmiconfig");
 const stepDefinitionPath = require("./stepDefinitionPath.js");
-const cypressExecutionInstance = require("./cypressExecutionInstance");
-
-jest.mock("./cypressExecutionInstance", () => ({
-  getArguments: jest.fn()
-}));
 
 jest.mock("fs", () => ({
-  readFileSync: jest.fn()
+  existsSync: jest.fn()
 }));
 
 jest.mock("cosmiconfig");
 
+const defaultNonGlobalStepDefinitionsPath = "cypress/integration";
+
 describe("load path from step definitions", () => {
   beforeEach(() => {
     cosmiconfig.mockReset();
-    fs.readFileSync.mockReset();
-    cypressExecutionInstance.getArguments.mockReset();
+    fs.existsSync.mockReset();
   });
 
-  test("Should throw error if both nonGlobalStepDefinitions and step_definitions are set in cosmic config", () => {
+  test("Should throw an error if nonGlobalStepDefinitions and stepDefinitions are not set and the default is wrong", () => {
+    const COMICONFIG_FILEPATH = "package.json";
     const loadMock = jest.fn().mockReturnValue({
       config: {
-        nonGlobalStepDefinitions: true,
-        step_definitions: "e2e/step_definitions"
-      }
+        nonGlobalStepDefinitions: true
+      },
+      filepath: COMICONFIG_FILEPATH
     });
     cosmiconfig.mockReturnValue({
       load: loadMock
     });
-    fs.readFileSync.mockReturnValue("{}");
+    fs.existsSync.mockReturnValue(false);
 
-    const errorMessage =
-      "Error! You can't have both step_definitions folder and nonGlobalStepDefinitions setup in cypress-cucumber-preprocessor configuration";
+    const errorMessage = `We've tried to resolve your step definitions at ${defaultNonGlobalStepDefinitionsPath}, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Currently your configuration is in: ${COMICONFIG_FILEPATH}. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.`;
     expect(stepDefinitionPath).throw(errorMessage);
   });
 
-  test("should return default path if coscmicconfig and cypress.json has not config properties", () => {
-    const appRoot = process.cwd();
+  test("Should throw an error if nonGlobalStepDefinitions and stepDefinitions are set but the folder doesn't exist", () => {
+    const COMICONFIG_FILEPATH = "package.json";
+    const stepDefinitions = "cypress/stepDefinitions";
+    const loadMock = jest.fn().mockReturnValue({
+      config: {
+        nonGlobalStepDefinitions: true,
+        stepDefinitions
+      },
+      filepath: COMICONFIG_FILEPATH
+    });
     cosmiconfig.mockReturnValue({
-      load: jest.fn()
+      load: loadMock
     });
-    fs.readFileSync.mockReturnValue("{}");
+    fs.existsSync.mockReturnValue(false);
 
-    expect(stepDefinitionPath()).to.equal(
-      `${appRoot}/cypress/support/step_definitions`
-    );
-    expect(fs.readFileSync.mock.calls[0][0]).to.equal(
-      `${appRoot}/cypress.json`
-    );
+    const errorMessage = `We've tried to resolve your step definitions at ${stepDefinitions}, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Currently your configuration is in: ${COMICONFIG_FILEPATH}. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.`;
+    expect(stepDefinitionPath).throw(errorMessage);
   });
 
-  test("should use fileServerFolder from cypress options for backward compability", () => {
+  test("should use the default stepDefinitions path for nonGlobalStepDefinitions", () => {
     const appRoot = process.cwd();
     const loadMock = jest.fn().mockReturnValue({
       config: {
-        commonPath: "./e2e/step-definitions/common"
+        nonGlobalStepDefinitions: true
       }
     });
     cosmiconfig.mockReturnValue({
       load: loadMock
     });
-    fs.readFileSync.mockReturnValue(`{
-      "fileServerFolder": "./e2e"
-    }`);
+    fs.existsSync.mockReturnValue(true);
 
-    expect(stepDefinitionPath()).to.equal(`./e2e/support/step_definitions`);
-    expect(fs.readFileSync.mock.calls[0][0]).to.equal(
-      `${appRoot}/cypress.json`
+    expect(stepDefinitionPath()).to.equal(
+      `${appRoot}/${defaultNonGlobalStepDefinitionsPath}`
     );
   });
 
-  test("should use config file for cypress when cypress is running with option --config-file", () => {
+  test("should use the stepDefinitions path for nonGlobalStepDefinitions", () => {
     const appRoot = process.cwd();
-    cosmiconfig.mockReturnValue({
-      load: jest.fn()
+    const loadMock = jest.fn().mockReturnValue({
+      config: {
+        stepDefinitions: "./e2e/support/step-definitions",
+        nonGlobalStepDefinitions: true
+      }
     });
-    fs.readFileSync.mockReturnValue(`{
-      "fileServerFolder": "./e2e"
-    }`);
-    cypressExecutionInstance.getArguments.mockReturnValue({
-      "config-file": "./e2e/cypress.json"
+    cosmiconfig.mockReturnValue({
+      load: loadMock
     });
+    fs.existsSync.mockReturnValue(true);
 
-    expect(stepDefinitionPath()).to.equal(`./e2e/support/step_definitions`);
-    expect(fs.readFileSync.mock.calls[0][0]).to.equal(
-      `${appRoot}/e2e/cypress.json`
+    expect(stepDefinitionPath()).to.equal(
+      `${appRoot}/e2e/support/step-definitions`
     );
   });
 
-  test("should use nonGlobalStepDefinitions from cosmiconfig", () => {
+  test("should use the stepDefinitions path", () => {
     const appRoot = process.cwd();
     const loadMock = jest.fn().mockReturnValue({
       config: {
-        nonGlobalStepDefinitions: true
+        stepDefinitions: "./e2e/support/step-definitions"
       }
     });
     cosmiconfig.mockReturnValue({
       load: loadMock
     });
-    fs.readFileSync.mockReturnValue(`{}`);
+    fs.existsSync.mockReturnValue(true);
+
+    expect(stepDefinitionPath()).to.equal(
+      `${appRoot}/e2e/support/step-definitions`
+    );
+  });
+
+  test("should return default path if stepDefinition are not configured and nonGlobalStepDefinitions are not set", () => {
+    const appRoot = process.cwd();
+    cosmiconfig.mockReturnValue({
+      load: jest.fn()
+    });
 
-    expect(stepDefinitionPath()).to.equal(`${appRoot}/cypress/integration`);
-    expect(fs.readFileSync.mock.calls[0][0]).to.equal(
-      `${appRoot}/cypress.json`
+    expect(stepDefinitionPath()).to.equal(
+      `${appRoot}/cypress/support/step_definitions`
     );
   });
 
-  test("should use step_definitions from cosmiconfig", () => {
+  test("should allow the backward compatible use of step_definitions in cosmiconfig", () => {
     const appRoot = process.cwd();
     const loadMock = jest.fn().mockReturnValue({
       config: {
@@ -118,13 +125,10 @@ describe("load path from step definitions", () => {
     cosmiconfig.mockReturnValue({
       load: loadMock
     });
-    fs.readFileSync.mockReturnValue(`{}`);
+    fs.existsSync.mockReturnValue(true);
 
     expect(stepDefinitionPath()).to.equal(
       `${appRoot}/e2e/support/step-definitions`
     );
-    expect(fs.readFileSync.mock.calls[0][0]).to.equal(
-      `${appRoot}/cypress.json`
-    );
   });
 });