zjsunit: Clear require cache also for templates.

This is necessary for the new `mock_template` helper added in
97ad6b6b62 to work correctly without
leaks, since it uses `mock_cjs` under the hood.

This logic was added in 216493aae8.
This commit is contained in:
Abhijeet Prasad Bodas 2021-06-14 16:05:28 +05:30 committed by Steve Howell
parent dd90083ed7
commit 09f8a8ec2b
1 changed files with 1 additions and 2 deletions

View File

@ -148,7 +148,6 @@ exports.zrequire = function (short_fn) {
};
const staticPath = path.resolve(__dirname, "../../static") + path.sep;
const templatesPath = staticPath + "templates" + path.sep;
exports.complain_about_unused_mocks = function () {
for (const filename of module_mocks.keys()) {
@ -177,7 +176,7 @@ exports.finish = function () {
used_module_mocks.clear();
for (const path of Object.keys(require.cache)) {
if (path.startsWith(staticPath) && !path.startsWith(templatesPath)) {
if (path.startsWith(staticPath)) {
delete require.cache[path];
}
}