The issue arises because my UI test scripts and API test scripts are organized in different folders and at different directory levels, but they share the same before() method in the e2e.ts file. And in before() method, I use jsonPath to analyze data.
before() method in e2e.ts file. readDataFile() method use jsonPath
before(() => {
const conditionFile = path.join('data', Constant.PreTest);
cy.task('readDataFile', conditionFile).then((data) => {
.....
});
})
Solution 1: Consolidate API and UI test scripts into the same folder to ensure consistent execution. Solution 2: Modify the before() method in e2e.ts to handle both API and UI test scripts seamlessly, regardless of their folder structure or directory level.