code: def test_to_json_with_format_vega(chart):
      json_spec = chart.to_json(format="vega")
      assert isinstance(json_spec, str)
      spec = json.loads(json_spec)
      assert_is_vega_spec(spec)
  
file_path: altair/tests/utils/test_compiler.py
imports: import json
  import pytest
  from altair import vegalite_compilers, Chart
label_desc: Use image node_id 5 for calling a global function with example usage: test_to_json_with_format_vega(chart) without return types