Skip to content

Commit ccc43e3

Browse files
arichard-infolgandecki
authored andcommitted
refactor(cypress-tags): refactor cypress-tags file after rebase (fix-conflicts)
1 parent 1e0ff7e commit ccc43e3

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

cypress-tags.js

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,50 @@ function parseArgsOrDefault(argPrefix, defaultValue) {
2929
}
3030

3131
const envGlob = parseArgsOrDefault("GLOB", false);
32-
debug("Found glob", envGlob);
3332
const envTags = parseArgsOrDefault("TAGS", "");
34-
debug("Found tag expression", envTags);
3533

36-
let defaultGlob = "cypress/integration/**/*.feature";
34+
let specGlob = envGlob || "cypress/integration/**/*.feature";
3735
let ignoreGlob = "";
38-
let usingCypressConf = true;
39-
40-
try {
41-
// TODO : curently we don't allow the override of the cypress.json path
42-
// maybe we can set this path in the plugin conf (package.json : "cypressConf": "test/cypress.json")
43-
const cypressConf = require("../../cypress.json");
44-
const integrationFolder =
45-
cypressConf && cypressConf.integrationFolder
46-
? cypressConf.integrationFolder.replace(/\/$/, "")
47-
: "cypress/integration";
48-
49-
if (cypressConf && cypressConf.ignoreTestFiles) {
50-
ignoreGlob = cypressConf.ignoreTestFiles;
51-
}
52-
53-
if (cypressConf && cypressConf.testFiles) {
54-
let testFiles = !Array.isArray(cypressConf.testFiles)
55-
? cypressConf.testFiles.split(",")
56-
: cypressConf.testFiles;
57-
testFiles = testFiles.map(pattern => `${integrationFolder}/${pattern}`);
58-
defaultGlob =
59-
testFiles.length > 1 ? `{${testFiles.join(",")}}` : testFiles[0];
60-
} else {
61-
defaultGlob = `${integrationFolder}/**/*.feature`;
36+
let usingCypressConf = false;
37+
38+
if (!envGlob) {
39+
try {
40+
// TODO : curently we don't allow the override of the cypress.json path
41+
// maybe we can set this path in the plugin conf (package.json : "cypressConf": "test/cypress.json")
42+
// eslint-disable-next-line import/no-unresolved,global-require
43+
const cypressConf = require("../../cypress.json");
44+
const integrationFolder =
45+
cypressConf && cypressConf.integrationFolder
46+
? cypressConf.integrationFolder.replace(/\/$/, "")
47+
: "cypress/integration";
48+
49+
if (cypressConf && cypressConf.ignoreTestFiles) {
50+
ignoreGlob = cypressConf.ignoreTestFiles;
51+
}
52+
53+
if (cypressConf && cypressConf.testFiles) {
54+
let testFiles = !Array.isArray(cypressConf.testFiles)
55+
? cypressConf.testFiles.split(",")
56+
: cypressConf.testFiles;
57+
testFiles = testFiles.map(pattern => `${integrationFolder}/${pattern}`);
58+
specGlob =
59+
testFiles.length > 1 ? `{${testFiles.join(",")}}` : testFiles[0];
60+
} else {
61+
specGlob = `${integrationFolder}/**/*.feature`;
62+
}
63+
console.log("Using cypress.json configuration:");
64+
console.log("Spec files: ", specGlob);
65+
if (ignoreGlob) console.log("Ignored files: ", ignoreGlob);
66+
} catch (err) {
67+
usingCypressConf = false;
68+
specGlob = "cypress/integration/**/*.feature";
69+
console.log("Failed to read cypress.json, using default configuration");
70+
console.log("Spec files: ", specGlob);
6271
}
63-
} catch (err) {
64-
usingCypressConf = false;
65-
defaultGlob = "cypress/integration/**/*.feature";
6672
}
6773

68-
if (envGlob) usingCypressConf = false; // in this case, we ignore the Cypress conf
69-
70-
const specGlob = envGlob ? envGlob.replace(/.*=/, "") : defaultGlob;
71-
72-
if (envGlob) {
73-
debug("Found glob", specGlob);
74-
}
74+
debug("Found glob", specGlob);
75+
debug("Found tag expression", envTags);
7576

7677
const paths = glob
7778
.sync(specGlob, {

0 commit comments

Comments
 (0)