0

是否可以在 Mountebank 存根之间共享变量?

这是一个高级示例:

存根 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}"
                  }
                 }]
              }

存根 B:


{
    "predicates": [
        {
            "matches": {
                "body": "approved=420"
            }
        }
    ],
    "responses": [
        {
            "is": {
                "statusCode": 200
                },
                "body": {
                      "transaction_id": "${TRANSACTION1}",
                      "amount": 420
                      }
              }

我为存根 B 尝试的复制 _behavior 方法似乎无法识别存根 A 中指定的变量。从文档来看,似乎我无法在这些存根之间使用复制。

4

1 回答 1

1

根据开发人员的说法,目前不支持此行为。见:https ://github.com/bbyars/mountebank/issues/476

于 2019-11-05T18:24:14.603 回答