Skip to content

Commit

Permalink
fix(commonpath): commonPath fixed for subdirectories with nonGlobalSt…
Browse files Browse the repository at this point in the history
…epDefinitions

see discussion in #594

closes #594 , closes #593
  • Loading branch information
lgandecki committed Jul 9, 2021
1 parent 4fb5873 commit 2054f3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/getStepDefinitionsPaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getStepDefinitionsPaths = (filePath) => {
let commonPath = config.commonPath || `${stepDefinitionPath()}/common/`;

if (config.commonPath) {
commonPath = path.resolve(appRoot, commonPath);
commonPath = `${path.resolve(appRoot, commonPath)}/`;
}

if (config.nonGlobalStepBaseDir) {
Expand Down
14 changes: 3 additions & 11 deletions lib/getStepDefinitionsPaths.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// file.only
/* eslint-disable global-require */
jest.mock("./stepDefinitionPath.js", () => () => "stepDefinitionPath");
jest.mock("glob", () => ({
Expand Down Expand Up @@ -28,16 +29,7 @@ describe("getStepDefinitionsPaths", () => {
});

it("should return the common folder defined by the developer", () => {
jest.mock("path", () => ({
resolve(appRoot, commonPath) {
return `./${appRoot}/${commonPath}`;
},
extname() {
return ".js";
},
}));

jest.spyOn(process, "cwd").mockImplementation(() => "cwd");
jest.spyOn(process, "cwd").mockImplementation(() => "/cwd/");

getConfig.mockReturnValue({
nonGlobalStepDefinitions: true,
Expand All @@ -47,7 +39,7 @@ describe("getStepDefinitionsPaths", () => {
const { getStepDefinitionsPaths } = require("./getStepDefinitionsPaths");

const actual = getStepDefinitionsPaths("/path");
const expected = "./cwd/myPath/**/*.+(js|ts|tsx)";
const expected = "/cwd/myPath/**/*.+(js|ts|tsx)";
expect(actual).to.include(expected);
});
it("should return the default non global step definition pattern", () => {
Expand Down

0 comments on commit 2054f3d

Please sign in to comment.