@@ -63,19 +63,43 @@ describe("getStepDefinitionsPaths", () => {
6363 expect ( actual ) . to . include ( expected ) ;
6464 } ) ;
6565
66- it ( "should return the overriden non global step definition pattern if nonGlobalStepBaseDir is defined", ( ) => {
67- jest . spyOn ( process , "cwd" ) . mockImplementation ( ( ) => "cwd" ) ;
68- getConfig . mockReturnValue ( {
66+ describe ( " nonGlobalStepBaseDir is defined", ( ) => {
67+ const path = "stepDefinitionPath/test.feature" ;
68+ const config = {
6969 nonGlobalStepDefinitions : true ,
7070 nonGlobalStepBaseDir : "nonGlobalStepBaseDir"
71+ } ;
72+
73+ beforeEach ( ( ) => {
74+ jest . spyOn ( process , "cwd" ) . mockImplementation ( ( ) => "cwd" ) ;
7175 } ) ;
72- // eslint-disable-next-line global-require
73- const { getStepDefinitionsPaths } = require ( "./getStepDefinitionsPaths" ) ;
74- const path = "stepDefinitionPath/test.feature" ;
75- const actual = getStepDefinitionsPaths ( path ) ;
76- const expected = "cwd/nonGlobalStepBaseDir/test/**/*.+(js|ts)" ;
7776
78- expect ( actual ) . to . include ( expected ) ;
79- expect ( actual ) . to . not . include ( "stepDefinitionPath/test/**/*.+(js|ts)" ) ;
77+ it ( "should return the overriden non global step definition pattern and default common folder" , ( ) => {
78+ getConfig . mockReturnValue ( config ) ;
79+
80+ const { getStepDefinitionsPaths } = require ( "./getStepDefinitionsPaths" ) ;
81+ const actual = getStepDefinitionsPaths ( path ) ;
82+
83+ const expectedNonGlobalDefinitionPattern =
84+ "cwd/nonGlobalStepBaseDir/test/**/*.+(js|ts)" ;
85+ const expectedCommonPath =
86+ "cwd/nonGlobalStepBaseDir/test/../common/**/*.+(js|ts)" ;
87+
88+ expect ( actual ) . to . include ( expectedNonGlobalDefinitionPattern ) ;
89+ expect ( actual ) . to . include ( expectedCommonPath ) ;
90+ expect ( actual ) . to . not . include ( "stepDefinitionPath/test/**/*.+(js|ts)" ) ;
91+ } ) ;
92+
93+ it ( "should return common folder defined by the dev and based on nonGlobalStepBaseDir" , ( ) => {
94+ getConfig . mockReturnValue ( { ...config , commonPath : "commonPath/" } ) ;
95+
96+ const { getStepDefinitionsPaths } = require ( "./getStepDefinitionsPaths" ) ;
97+ const actual = getStepDefinitionsPaths ( path ) ;
98+
99+ const expectedCommonPath =
100+ "cwd/nonGlobalStepBaseDir/test/../commonPath/**/*.+(js|ts)" ;
101+
102+ expect ( actual ) . to . include ( expectedCommonPath ) ;
103+ } ) ;
80104 } ) ;
81105} ) ;
0 commit comments