How to require injected javascript files into another file

73 views
Skip to first unread message

Clifton Ho

unread,
Oct 16, 2024, 5:35:13 PM10/16/24
to mountebank-discuss
I am trying to use Jest to create unit tests for a file that is directly injected via mountebank ( see below) specifically virtualizeAPI.js file. However, when I try to export the module and invoke mounteBank, the file throws an error. is that any work around to require it into another file for unit testing purposes?

{
"predicates": [
{
"and": [
{
"equals": {
"method": "POST",
"path": "/credit-card-transactions/CardTranSandUATOct/accounts/transactions"
}
},
{
"inject": "(config) => {\n\n config.state.configYML='lib/config/post-accounts-transactions.yml';\n config.state.apiSchema='../../../../lib/responseSchema/post-accounts-transactions-schema.js' ;\n config.state.databaseYML='lib/config/database-post-accounts-transactions.yml'; \n return true;\n}"
},
{
"exists": {
"body": true
}
}
]
}
],
"responses": [
{
"inject": "<%- stringify(filename, '/lib/core/virtualizeAPI.js') %>"
}
]
},
Reply all
Reply to author
Forward
0 new messages