You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(stepdefinitionpath): do not rely on cypress configuration for determining the stepDefinitionPath
Relying on any parts of the cypress configuration has been problematic since the beginning, it was
time to use only the configuration that we own. This is a breaking change but it should be
relatively easy to adjust to it. And for people using defaults - nothing changes. Should improve
performance especially on Windows.
BREAKING CHANGE: You need to configure the stepDefinitions if you use the nonGlobalStepDefinitions
option.
re #295 , fix#283
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ Option | Default value | Description
86
86
------------ | ------------- | -------------
87
87
commonPath | `cypress/integration/common` when `nonGlobalStepDefinitions` is true <br> `cypress/support/step_definitions` when `nonGlobalStepDefinitions` is false | Define the path to a folder containing all common step definitions of your tests
88
88
nonGlobalStepDefinitions | false | If true use the Cypress Cucumber Preprocessor Style pattern for placing step definitions files. If false, we will use the "oldschool" (everything is global) Cucumber style
89
-
step_definitions | `cypress/support/step_definitions` | Path to the folder containing our step definitions
89
+
stepDefinitions | `cypress/integration` when `nonGlobalStepDefinitions` is true <br> `cypress/support/step_definitions`when `nonGlobalStepDefinitions` is false | Path to the folder containing our step definitions.
`We've tried to resolve your step definitions at ${relativePath}, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Currently your configuration is in: ${filepath}. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.`
test("Should throw error if both nonGlobalStepDefinitions and step_definitions are set in cosmic config",()=>{
19
+
test("Should throw an error if nonGlobalStepDefinitions and stepDefinitions are not set and the default is wrong",()=>{
20
+
constCOMICONFIG_FILEPATH="package.json";
24
21
constloadMock=jest.fn().mockReturnValue({
25
22
config: {
26
-
nonGlobalStepDefinitions: true,
27
-
step_definitions: "e2e/step_definitions"
28
-
}
23
+
nonGlobalStepDefinitions: true
24
+
},
25
+
filepath: COMICONFIG_FILEPATH
29
26
});
30
27
cosmiconfig.mockReturnValue({
31
28
load: loadMock
32
29
});
33
-
fs.readFileSync.mockReturnValue("{}");
30
+
fs.existsSync.mockReturnValue(false);
34
31
35
-
consterrorMessage=
36
-
"Error! You can't have both step_definitions folder and nonGlobalStepDefinitions setup in cypress-cucumber-preprocessor configuration";
32
+
consterrorMessage=`We've tried to resolve your step definitions at ${defaultNonGlobalStepDefinitionsPath}, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Currently your configuration is in: ${COMICONFIG_FILEPATH}. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.`;
37
33
expect(stepDefinitionPath).throw(errorMessage);
38
34
});
39
35
40
-
test("should return default path if coscmicconfig and cypress.json has not config properties",()=>{
41
-
constappRoot=process.cwd();
36
+
test("Should throw an error if nonGlobalStepDefinitions and stepDefinitions are set but the folder doesn't exist",()=>{
consterrorMessage=`We've tried to resolve your step definitions at ${stepDefinitions}, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Currently your configuration is in: ${COMICONFIG_FILEPATH}. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.`;
52
+
expect(stepDefinitionPath).throw(errorMessage);
53
53
});
54
54
55
-
test("should use fileServerFolder from cypress options for backward compability",()=>{
55
+
test("should use the default stepDefinitions path for nonGlobalStepDefinitions",()=>{
0 commit comments