Repository: TheBrainFamily/cypress-cucumber-preprocessor
Pull request #356 (2020-04-03 22:11:57)

chore(deps): [security] bump minimist from 1.2.2 to 1.2.3
Bumps [minimist](https://github.com/substack/minimist) from 1.2.2 to 1.2.3. **This update includes a security fix.**
<details>
<summary>Vulnerabilities fixed</summary>
<p><em>Sourced from <a href="https://github.com/advisories/GHSA-vh95-rmgr-6w4m">The GitHub Security Advisory Database</a>.</em></p>
<blockquote>
<p><strong>High severity vulnerability that affects minimist</strong>
minimist before 1.2.2 could be tricked into adding or modifying properties of Object.prototype using a &quot;constructor&quot; or &quot;<strong>proto</strong>&quot; payload.</p>
<p>Affected versions: &gt;= 1.0.0 &lt; 1.2.3</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/substack/minimist/commit/6457d7440a47f329c12c4a5abfbce211c4235b93"><code>6457d74</code></a> 1.2.3</li>
<li><a href="https://github.com/substack/minimist/commit/38a4d1caead72ef99e824bb420a2528eec03d9ab"><code>38a4d1c</code></a> even more aggressive checks for protocol pollution</li>
<li><a href="https://github.com/substack/minimist/commit/13c01a5327736903704984b7f65616b8476850cc"><code>13c01a5</code></a> more failing proto pollution tests</li>
<li>See full diff in <a href="https://github.com/substack/minimist/compare/1.2.2...1.2.3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=minimist&package-manager=npm_and_yarn&previous-version=1.2.2&new-version=1.2.3)](https://dependabot.com/compatibility-score/?dependency-name=minimist&package-manager=npm_and_yarn&previous-version=1.2.2&new-version=1.2.3)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>


Patch:
diff --git a/README.md b/README.md
index e8e538f..0ae679b 100644
--- a/README.md
+++ b/README.md
@@ -328,6 +328,7 @@ Example:
 ```
 
 Please note - we use our own cypress-tags wrapper to speed things up.
+This wrapper calls the cypress executable from local modules and if not found it falls back to the globally installed one.
 For more details and examples please take a look to the [example repo](https://github.com/TheBrainFamily/cypress-cucumber-example).
 
 ### Ignoring specific scenarios using tags when executing test runner
@@ -408,6 +409,14 @@ Note, that unlike WebStorm which will correctly identify multiple implementation
 
 ## TypeScript Support
 
+### Install
+
+Install the plug-in type definitions:
+
+```shell
+npm install --save-dev @types/cypress-cucumber-preprocessor
+```
+
 ### With Webpack
 You can also use a Webpack loader to process feature files (TypeScript supported). To see how it is done please take 
 a look here: [cypress-cucumber-webpack-typescript-example](https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example)
diff --git a/cypress-tags.js b/cypress-tags.js
index b882171..0846d12 100755
--- a/cypress-tags.js
+++ b/cypress-tags.js
@@ -59,12 +59,20 @@ paths.forEach(featurePath => {
   }
 });
 
+function getOsSpecificExecutable(command) {
+  return process.platform === "win32" ? `${command}.cmd` : command;
+}
+
+function getCypressExecutable() {
+  const command = getOsSpecificExecutable(`${__dirname}/../.bin/cypress`);
+  // fallback to the globally installed cypress instead
+  return fs.existsSync(command) ? command : getOsSpecificExecutable("cypress");
+}
+
 try {
   if (featuresToRun.length || envTags === "") {
     execFileSync(
-      process.platform === "win32"
-        ? `cypress.cmd`
-        : `${__dirname}/../.bin/cypress`,
+      getCypressExecutable(),
       [...process.argv.slice(2), "--spec", featuresToRun.join(",")],
       {
         stdio: [process.stdin, process.stdout, process.stderr]
diff --git a/lib/cukejson/cucumberDataCollector.js b/lib/cukejson/cucumberDataCollector.js
index 55570a3..b494d38 100644
--- a/lib/cukejson/cucumberDataCollector.js
+++ b/lib/cukejson/cucumberDataCollector.js
@@ -1,5 +1,5 @@
 const { Parser } = require("gherkin");
-const statuses = require("cucumber").Status;
+const statuses = require("cucumber/lib/status").default;
 
 class CucumberDataCollector {
   constructor(uri, spec) {
diff --git a/lib/cukejson/generateCucumberJson.js b/lib/cukejson/generateCucumberJson.js
index f77de96..ad55bc7 100644
--- a/lib/cukejson/generateCucumberJson.js
+++ b/lib/cukejson/generateCucumberJson.js
@@ -1,6 +1,7 @@
 const { EventEmitter } = require("events");
 const { generateEvents } = require("gherkin");
-const { JsonFormatter, formatterHelpers } = require("cucumber");
+const JsonFormatter = require("cucumber/lib/formatter/json_formatter").default;
+const formatterHelpers = require("cucumber/lib/formatter/helpers");
 
 function generateCucumberJson(state) {
   let output = "";
diff --git a/lib/getStepDefinitionsPaths.js b/lib/getStepDefinitionsPaths.js
index 42ada5f..3744fd6 100644
--- a/lib/getStepDefinitionsPaths.js
+++ b/lib/getStepDefinitionsPaths.js
@@ -1,16 +1,23 @@
+const path = require("path");
 const glob = require("glob");
 const { getConfig } = require("./getConfig");
 const stepDefinitionPath = require("./stepDefinitionPath.js");
 const { getStepDefinitionPathsFrom } = require("./getStepDefinitionPathsFrom");
 
 const getStepDefinitionsPaths = filePath => {
+  const appRoot = process.cwd();
   let paths = [];
   const config = getConfig();
   if (config && config.nonGlobalStepDefinitions) {
     const nonGlobalPattern = `${getStepDefinitionPathsFrom(
       filePath
     )}/**/*.+(js|ts)`;
-    const commonPath = config.commonPath || `${stepDefinitionPath()}/common/`;
+
+    let commonPath = config.commonPath || `${stepDefinitionPath()}/common/`;
+
+    if (config.commonPath) {
+      commonPath = path.resolve(appRoot, commonPath);
+    }
     const commonDefinitionsPattern = `${commonPath}**/*.+(js|ts)`;
     paths = paths.concat(glob.sync(nonGlobalPattern));
     paths = paths.concat(glob.sync(commonDefinitionsPattern));
diff --git a/package-lock.json b/package-lock.json
index d1f1642..c452b2a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13446,9 +13446,9 @@
       }
     },
     "minimist": {
-      "version": "1.2.2",
-      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.2.tgz",
-      "integrity": "sha512-rIqbOrKb8GJmx/5bc2M0QchhUouMXSpd1RTclXsB41JdL+VtnojfaJR+h7F9k18/4kHUsBFgk80Uk+q569vjPA=="
+      "version": "1.2.3",
+      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.3.tgz",
+      "integrity": "sha512-+bMdgqjMN/Z77a6NlY/I3U5LlRDbnmaAk6lDveAPKwSpcPM4tKAuYsvYF8xjhOPXhOYGe/73vVLVez5PW+jqhw=="
     },
     "minimist-options": {
       "version": "3.0.2",


Test patch:
diff --git a/lib/createTestFromScenario.js b/lib/createTestFromScenario.js
index 6086a4a..c30a78d 100644
--- a/lib/createTestFromScenario.js
+++ b/lib/createTestFromScenario.js
@@ -1,5 +1,5 @@
 /* eslint-disable prefer-template */
-const statuses = require("cucumber").Status;
+const statuses = require("cucumber/lib/status").default;
 const {
   resolveAndRunStepDefinition,
   resolveAndRunBeforeHooks,
diff --git a/lib/cukejson/cucumberDataCollector.test.js b/lib/cukejson/cucumberDataCollector.test.js
index 272f837..7f68f64 100644
--- a/lib/cukejson/cucumberDataCollector.test.js
+++ b/lib/cukejson/cucumberDataCollector.test.js
@@ -1,5 +1,5 @@
 const fs = require("fs");
-const statuses = require("cucumber").Status;
+const statuses = require("cucumber/lib/status").default;
 const { CucumberDataCollector } = require("./cucumberDataCollector");
 const { generateCucumberJson } = require("./generateCucumberJson");
 
diff --git a/lib/getStepDefinitionsPaths.test.js b/lib/getStepDefinitionsPaths.test.js
index 34c3e70..212cb09 100644
--- a/lib/getStepDefinitionsPaths.test.js
+++ b/lib/getStepDefinitionsPaths.test.js
@@ -1,3 +1,4 @@
+/* eslint-disable global-require */
 jest.mock("./stepDefinitionPath.js", () => () => "stepDefinitionPath");
 jest.mock("glob", () => ({
   sync(pattern) {
@@ -5,17 +6,19 @@ jest.mock("glob", () => ({
   }
 }));
 
+let getConfig;
+
 describe("getStepDefinitionsPaths", () => {
-  it("should return the default common folder", () => {
+  beforeEach(() => {
     jest.resetModules();
-    jest.mock("cosmiconfig", () => () => ({
-      load: () => ({
-        config: {
-          nonGlobalStepDefinitions: true
-        }
-      })
-    }));
-    // eslint-disable-next-line global-require
+    ({ getConfig } = require("./getConfig"));
+    jest.mock("./getConfig");
+  });
+  it("should return the default common folder", () => {
+    getConfig.mockReturnValue({
+      nonGlobalStepDefinitions: true
+    });
+
     const { getStepDefinitionsPaths } = require("./getStepDefinitionsPaths");
 
     const actual = getStepDefinitionsPaths("/path");
@@ -23,22 +26,29 @@ describe("getStepDefinitionsPaths", () => {
 
     expect(actual).to.include(expected);
   });
-  it("should return the common folder defined by the developper", () => {
-    jest.resetModules();
-    jest.mock("cosmiconfig", () => () => ({
-      load: () => ({
-        config: {
-          nonGlobalStepDefinitions: true,
-          commonPath: "myPath/"
-        }
-      })
+
+  it("should return the common folder defined by the developer", () => {
+    jest.mock("path", () => ({
+      resolve(appRoot, commonPath) {
+        return `./${appRoot}/${commonPath}`;
+      },
+      extname() {
+        return ".js";
+      }
     }));
-    // eslint-disable-next-line global-require
+
+    jest.mock("fs");
+    jest.spyOn(process, "cwd").mockImplementation(() => "cwd");
+
+    getConfig.mockReturnValue({
+      nonGlobalStepDefinitions: true,
+      commonPath: "myPath/"
+    });
+
     const { getStepDefinitionsPaths } = require("./getStepDefinitionsPaths");
 
     const actual = getStepDefinitionsPaths("/path");
-    const expected = "myPath/**/*.+(js|ts)";
-
+    const expected = "./cwd/myPath/**/*.+(js|ts)";
     expect(actual).to.include(expected);
   });
 });