forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cypress-tags.js): changed GLOB option handling to fix issues with…
… commas in glob patterns Changed how GLOB option is passed and handled to prevent current issues with passing it through -env caused by Cypress expecting a comma delimited string of variables. fix #429
- Loading branch information
1 parent
77dbacb
commit d4bb762
Showing
4 changed files
with
166 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const { stripCLIArguments, getGlobArg } = require("./tagsHelper"); | ||
|
||
const processArgv = process.argv; | ||
|
||
describe("stripCLIArguments function should return correct args array", () => { | ||
beforeEach(() => { | ||
process.argv = ["path/to/node", "path/to/file", "run"]; | ||
}); | ||
test("when only target option is present", () => { | ||
process.argv.push(...["-g", "cypress/integration/**/*.feature"]); | ||
expect(stripCLIArguments(["-g"])).to.eql(["run"]); | ||
}); | ||
test("when target option is a word", () => { | ||
process.argv.push(...["--glob", "cypress/integration/**/*.feature"]); | ||
expect(stripCLIArguments(["--glob"])).to.eql(["run"]); | ||
}); | ||
test("when option doesn't have a value tied to it", () => { | ||
process.argv.push(...["-g"]); | ||
expect(stripCLIArguments(["-g"])).to.eql(["run"]); | ||
}); | ||
test("when there are multiple options but only one is target for removal", () => { | ||
process.argv.push(...["-g", "-t"]); | ||
expect(stripCLIArguments(["-g"])).to.eql(["run", "-t"]); | ||
}); | ||
test("when there are multiple options to remove", () => { | ||
process.argv.push(...["-g", "-t", "cypress tags string"]); | ||
expect(stripCLIArguments(["-g", "-t"])).to.eql(["run"]); | ||
}); | ||
|
||
test("when option is coupled with other ones like -tg", () => { | ||
process.argv.push(...["-tg", "cypress/integration/**/*.feature"]); | ||
expect(stripCLIArguments(["-t"])).to.eql([ | ||
"run", | ||
"-g", | ||
"cypress/integration/**/*.feature", | ||
]); | ||
}); | ||
|
||
test("when option is coupled with other ones like -gt where t has a value", () => { | ||
process.argv.push(...["-gt", "cypress tags string"]); | ||
expect(stripCLIArguments(["-t"])).to.eql(["run", "-g"]); | ||
}); | ||
|
||
afterEach(() => { | ||
process.argv = processArgv; | ||
}); | ||
}); | ||
|
||
describe("getGlobArg function should return", () => { | ||
beforeEach(() => { | ||
process.argv = ["path/to/node", "path/to/file", "run"]; | ||
}); | ||
test("glob pattern when using -g or --glob option", () => { | ||
process.argv.push(...["-g", "cypress/integration/**/*.feature"]); | ||
expect(getGlobArg()).to.equal("cypress/integration/**/*.feature"); | ||
}); | ||
test("glob pattern containing commas when using -g option", () => { | ||
process.argv.push(...["-g", "cypress/integration/**/{1,2}*.feature"]); | ||
expect(getGlobArg()).to.equal("cypress/integration/**/{1,2}*.feature"); | ||
}); | ||
|
||
test("glob pattern when using env variables GLOB=", () => { | ||
process.argv.push(...["-e", "GLOB=cypress/integration/**/*.feature"]); | ||
expect(getGlobArg()).to.equal("cypress/integration/**/*.feature"); | ||
}); | ||
|
||
afterEach(() => { | ||
process.argv = processArgv; | ||
}); | ||
}); |