Skip to content

Commit

Permalink
Chore: (tests) clearCache on module load is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed May 15, 2021
1 parent d5d868b commit 96c2ae5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/utils.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import path from 'path';
import { entry } from './constants';

export function load(relPath) {
export function load(relPath, clearCache) {
const absPath = path.resolve(entry, relPath);

delete require.cache[require.resolve(absPath)];
if (clearCache) delete require.cache[require.resolve(absPath)];
// eslint-disable-next-line security/detect-non-literal-require
const result = require(absPath);

delete require.cache[require.resolve(absPath)];
if (clearCache) delete require.cache[require.resolve(absPath)];

return result;
}
Expand Down

0 comments on commit 96c2ae5

Please sign in to comment.