In many of my tests, I create a new slqite database and want to use the name of the test file as the sqlite DBname. This way, all my DB tests are isolated from each other.
As a related question: I would like my setupTestFrameworkScriptFile to be able to read config items (an Object) from the test. Is there a standard way to pass these configs from test to TestFramework?
Here is an example: In myclass.test.js
:
// "tell" the setup file I'm named 'myclass'
global.testId = function () {
return "myclass"
}
In setupTestFrameworkScriptFile
:
beforeAll(async () => {
// if the test supports this method
if (typeof testId === 'undefined') {
return
}
// create an sqlite DB with that name
_createAndSyncDb(testId)
Instead I would like the code in setupTestFrameworkScriptFile
to read the filename from the Jest environment, removing the need for the test and setupTestFrameworkScriptFile to both know about a previously agreed upon method named testId
.
Aucun commentaire:
Enregistrer un commentaire