You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.
There is a missing feature, that when I use useCleanCache: true, I can't specify a file/folder to be excluded from the cleaning, and to remain as a chached module.
The problems is this:
I have a file that creates an in-memory database with bookshelf.js (and a few options setting the connection is to a sqlite db). If I use useCleanCache: true, that file will be "unloaded" and when I require it again in my tests, it will be loaded again.
The result of this, will be that I will have an unlodaded in-memory database and a new in-memory database.
Notes:
I know there is a discussion if I should or shouldn't test with a db or not. I know it's not the best practice to do it, because it won't be a real unit test, but I would like to in this case. Also, setting up a real db for testing would make the testing slower. I don't want to enter in this discusion right now :D
The solution:
Add a new option: remainingCache: [RegExp] which will contain an array of RegExps, and will be used only if useCleanCache: true. This will change the override of m._cache = {} with an object filled with the original modules that the file name matched any of the RegExps.
I will make a PR with this if you are ok!
The text was updated successfully, but these errors were encountered:
There is a missing feature, that when I use
useCleanCache: true
, I can't specify a file/folder to be excluded from the cleaning, and to remain as a chached module.The problems is this:
I have a file that creates an in-memory database with bookshelf.js (and a few options setting the connection is to a sqlite db). If I use
useCleanCache: true
, that file will be "unloaded" and when I require it again in my tests, it will be loaded again.The result of this, will be that I will have an unlodaded in-memory database and a new in-memory database.
Notes:
I know there is a discussion if I should or shouldn't test with a db or not. I know it's not the best practice to do it, because it won't be a real unit test, but I would like to in this case. Also, setting up a real db for testing would make the testing slower. I don't want to enter in this discusion right now :D
The solution:
Add a new option:
remainingCache: [RegExp]
which will contain an array of RegExps, and will be used only ifuseCleanCache: true
. This will change the override ofm._cache = {}
with an object filled with the original modules that the file name matched any of the RegExps.I will make a PR with this if you are ok!
The text was updated successfully, but these errors were encountered: