code: def test_metrics_diff(dvc, mocker, capsys):
      cli_args = parse_args(
          [
              "metrics",
              "diff",
              "HEAD~10",
              "HEAD~1",
              "--all",
              "--md",
              "--targets",
              "target1",
              "target2",
              "--no-path",
          ]
      )
  
      assert cli_args.func == CmdMetricsDiff
  
      cmd = cli_args.func(cli_args)
      diff = {
          "diff": {"metrics.yaml": {"": {"old": 1, "new": 3}}},
          "errors": {"workspace": Exception},
      }
      metrics_diff = mocker.patch(
          "dvc.repo.metrics.diff.diff", return_value=diff
      )
      show_diff_mock = mocker.patch("dvc.compare.show_diff")
  
      assert cmd.run() == 0
  
      metrics_diff.assert_called_once_with(
          cmd.repo,
          targets=["target1", "target2"],
          a_rev="HEAD~10",
          b_rev="HEAD~1",
          all=True,
      )
      show_diff_mock.assert_called_once_with(
          diff["diff"],
          title="Metric",
          no_path=True,
          precision=5,
          markdown=True,
          round_digits=True,
          a_rev="HEAD~10",
          b_rev="HEAD~1",
      )
  
imports: import json
  from dvc.cli import parse_args
  from dvc.commands.metrics import CmdMetricsDiff, CmdMetricsShow
label_desc: Use image node_id 1 for calling a global function with example usage: test_metrics_diff(dvc, mocker, capsys) without return types