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.
feat: step definitions related to the feature file (#121)
- Loading branch information
Showing
9 changed files
with
141 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
getStepDefinitionPathsFrom: filePath => | ||
filePath.replace(path.extname(filePath), "") | ||
}; |
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,7 @@ | ||
const { getStepDefinitionPathsFrom } = require("./getStepDefinitionPathsFrom"); | ||
|
||
test("getStepDefinitionPathsFrom", () => { | ||
expect( | ||
getStepDefinitionPathsFrom("/home/lgandecki/someComplex_.feature") | ||
).equal("/home/lgandecki/someComplex_"); | ||
}); |
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,24 @@ | ||
const glob = require("glob"); | ||
const cosmiconfig = require("cosmiconfig"); | ||
const stepDefinitionPath = require("./stepDefinitionPath.js"); | ||
const { getStepDefinitionPathsFrom } = require("./getStepDefinitionPathsFrom"); | ||
|
||
const getStepDefinitionsPaths = filePath => { | ||
let paths = []; | ||
const explorer = cosmiconfig("cypress-cucumber-preprocessor", { sync: true }); | ||
const loaded = explorer.load(); | ||
if (loaded && loaded.config && loaded.config.nonGlobalStepDefinitions) { | ||
const nonGlobalPattern = `${getStepDefinitionPathsFrom( | ||
filePath | ||
)}/**/*.+(js|ts)`; | ||
const commonDefinitionsPattern = `${stepDefinitionPath()}/common/**/*.+(js|ts)`; | ||
paths = paths.concat(glob.sync(nonGlobalPattern)); | ||
paths = paths.concat(glob.sync(commonDefinitionsPattern)); | ||
} else { | ||
const pattern = `${stepDefinitionPath()}/**/*.+(js|ts)`; | ||
paths = paths.concat(glob.sync(pattern)); | ||
} | ||
return paths; | ||
}; | ||
|
||
module.exports = { getStepDefinitionsPaths }; |
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,3 @@ | ||
const loader = require("./lib/loader"); | ||
|
||
module.exports = loader; |
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