Is it possible to share a variable between Mountebank stubs?
Here's a high level example:
Stub A:
{
"predicates": [
{
"matches": {
"body": "amount=420"
}
}
],
"responses": [
{
"is": {
"statusCode": 200
},
"body": {
"transaction_id": "123456",
"amount": 420
},
"_behaviors": {
"copy": [{
"from": {"query": "transaction_id"},
"into": "${TRANSACTION1}",
"using": {
"method": "regex",
"selector": "(?<=transaction_id%5D=).{6}"
}
}]
}
Stub B:
{
"predicates": [
{
"matches": {
"body": "approved=420"
}
}
],
"responses": [
{
"is": {
"statusCode": 200
},
"body": {
"transaction_id": "${TRANSACTION1}",
"amount": 420
}
}
The copy _behavior approaches I have tried for Stub B do not seem to recognize the variable specified in Stub A. From the documentation, it seems as though I cannot use copy between these stubs.
As per the developer, this behavior isn't supported at this time. See: https://github.com/bbyars/mountebank/issues/476