Skip to content

Commit

Permalink
fix(testing): recalculate cypress targets when cypress config changes (
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Dec 6, 2023
1 parent bda1c7d commit 0618ba4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/cypress/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ function getCypressConfig(
if (tsConfigPath) {
const unregisterTsProject = registerTsProject(tsConfigPath);
try {
module = require(resolvedPath);
module = load(resolvedPath);
} finally {
unregisterTsProject();
}
} else {
module = require(resolvedPath);
module = load(resolvedPath);
}
} else {
module = require(resolvedPath);
module = load(resolvedPath);
}
return module.default ?? module;
}
Expand All @@ -297,3 +297,18 @@ function getInputs(
},
];
}

/**
* Load the module after ensuring that the require cache is cleared.
*/
function load(path: string): any {
// Clear cache if the path is in the cache
if (require.cache[path]) {
for (const k of Object.keys(require.cache)) {
delete require.cache[k];
}
}

// Then require
return require(path);
}

0 comments on commit 0618ba4

Please sign in to comment.