Skip to content

Commit

Permalink
fix: unable to find jsons folder when cypress config is not in projec…
Browse files Browse the repository at this point in the history
…t root (#97)
  • Loading branch information
LironEr authored Aug 10, 2022
1 parent 70c7146 commit 3352be3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async function setConfig(config) {
setLoggerQuietMode(quiet === true);
initDebugLog(debug === true);

debugLog(`cwd: ${process.cwd()}`);
debugLog(`cypress.json: ${JSON.stringify(config)}`);
debugLog(`simple config: ${JSON.stringify(_config)}`);

Expand All @@ -35,10 +36,10 @@ async function extractConfigFileOptions(configFile) {
const configFilePath = path.resolve(configFile);
const configFileExt = path.extname(configFile);

if(configFileExt === '.json') {
return await fse.readJson(configFilePath)
if (configFileExt === '.json') {
return await fse.readJson(configFilePath);
} else if (configFileExt === '.js') {
return require(configFilePath)
return require(configFilePath);
} else {
throw Error(`configFile ${configFile} cannot be resolved in reporterOptions. Supported extensions .json and .js`);
}
Expand Down Expand Up @@ -66,7 +67,7 @@ async function getSimpleCypressConfig(config) {

const reporterOptions = (await extractReporterOptions(config.reporterOptions)) || {};

reporterOptions['reportDir'] = reporterOptions['reportDir'] || path.join(baseDir, consts.defaultHtmlOutputFolder);
reporterOptions['reportDir'] = path.join(baseDir, reporterOptions['reportDir'] || consts.defaultHtmlOutputFolder);
const jsonDir = path.join(reporterOptions.reportDir, '/.jsons');

return {
Expand Down

0 comments on commit 3352be3

Please sign in to comment.