Repository: TheBrainFamily/cypress-cucumber-preprocessor
Pull request #181 (2019-06-12 16:17:54)

Move test to another file to ensure setting the TAGS env correctly


Patch:
diff --git a/lib/setup.js b/lib/setup.js
new file mode 100644
index 0000000..d5aa4b5
--- /dev/null
+++ b/lib/setup.js
@@ -0,0 +1,37 @@
+/* eslint-disable global-require */
+/* global jest */
+const fs = require("fs");
+const { Parser } = require("gherkin");
+const {
+  defineParameterType,
+  defineStep,
+  when,
+  then,
+  given,
+  and,
+  but
+} = require("./resolveStepDefinition");
+
+window.defineParameterType = defineParameterType;
+window.when = when;
+window.then = then;
+window.given = given;
+window.and = and;
+window.but = but;
+window.defineStep = defineStep;
+window.cy = {
+  log: jest.fn()
+};
+
+window.Cypress = {
+  env: jest.fn()
+};
+
+const readAndParseFeatureFile = featureFilePath => {
+  const spec = fs.readFileSync(featureFilePath);
+  return new Parser().parse(spec.toString());
+};
+
+module.exports = {
+  readAndParseFeatureFile
+};


Test patch:
diff --git a/lib/resolveStepDefinition.test.js b/lib/resolveStepDefinition.test.js
index 6dbbb8c..06e454a 100644
--- a/lib/resolveStepDefinition.test.js
+++ b/lib/resolveStepDefinition.test.js
@@ -1,37 +1,7 @@
 /* eslint-disable global-require */
 /* global jest */
-const fs = require("fs");
-const { Parser } = require("gherkin");
+const { readAndParseFeatureFile } = require("./setup");
 const { createTestsFromFeature } = require("./createTestsFromFeature");
-const {
-  defineParameterType,
-  defineStep,
-  when,
-  then,
-  given,
-  and,
-  but
-} = require("./resolveStepDefinition");
-
-window.defineParameterType = defineParameterType;
-window.when = when;
-window.then = then;
-window.given = given;
-window.and = and;
-window.but = but;
-window.defineStep = defineStep;
-window.cy = {
-  log: jest.fn()
-};
-
-window.Cypress = {
-  env: jest.fn()
-};
-
-const readAndParseFeatureFile = featureFilePath => {
-  const spec = fs.readFileSync(featureFilePath);
-  return new Parser().parse(spec.toString());
-};
 
 describe("Scenario Outline", () => {
   require("../cypress/support/step_definitions/scenario_outline_integer");
@@ -99,41 +69,7 @@ describe("Tags implementation", () => {
   );
 });
 
-describe("Tags inheritance", () => {
-  window.Cypress = {
-    env: () => "@inherited-tag and @own-tag"
-  };
-  require("../cypress/support/step_definitions/tags_implementation_with_env_set");
-
-  createTestsFromFeature(
-    readAndParseFeatureFile("./cypress/integration/TagsInheritance.feature")
-  );
-});
-
-// TODO we need to take a look why these do not work properly, but as long as they run correctly with cypress run we can skip for now.
-describe.skip("Tags with env TAGS set", () => {
-  window.Cypress = {
-    env: () => "@test-tag and not @ignore-tag"
-  };
-  require("../cypress/support/step_definitions/tags_implementation_with_env_set");
-
-  createTestsFromFeature(
-    readAndParseFeatureFile(
-      "./cypress/integration/TagsImplementationWithEnvSet.feature"
-    )
-  );
-
-  createTestsFromFeature(
-    readAndParseFeatureFile(
-      "./cypress/integration/TagsImplementationWithEnvSetScenarioLevel.feature"
-    )
-  );
-});
-
 describe("Smart tagging", () => {
-  window.Cypress = {
-    env: () => ""
-  };
   require("../cypress/support/step_definitions/smart_tagging");
 
   createTestsFromFeature(
@@ -156,3 +92,22 @@ describe("defineStep", () => {
     readAndParseFeatureFile("./cypress/integration/DefineStep.feature")
   );
 });
+
+describe("Tags with env TAGS set", () => {
+  window.Cypress = {
+    env: () => "@test-tag and not @ignore-tag"
+  };
+  require("../cypress/support/step_definitions/tags_implementation_with_env_set");
+
+  createTestsFromFeature(
+    readAndParseFeatureFile(
+      "./cypress/integration/TagsImplementationWithEnvSet.feature"
+    )
+  );
+
+  createTestsFromFeature(
+    readAndParseFeatureFile(
+      "./cypress/integration/TagsImplementationWithEnvSetScenarioLevel.feature"
+    )
+  );
+});
diff --git a/lib/tagsInheritance.test.js b/lib/tagsInheritance.test.js
new file mode 100644
index 0000000..eba051c
--- /dev/null
+++ b/lib/tagsInheritance.test.js
@@ -0,0 +1,16 @@
+/* eslint-disable global-require */
+/* global jest */
+const { readAndParseFeatureFile } = require("./setup");
+const { createTestsFromFeature } = require("./createTestsFromFeature");
+
+describe("Tags inheritance", () => {
+  window.Cypress = {
+    env: () => "@inherited-tag and @own-tag"
+  };
+
+  require("../cypress/support/step_definitions/tags_implementation_with_env_set");
+
+  createTestsFromFeature(
+    readAndParseFeatureFile("./cypress/integration/TagsInheritance.feature")
+  );
+});