code: def test_to_json_validate(fig1):
      dict1 = fig1.to_dict()
      dict1["layout"]["bogus"] = 37
  
      with pytest.raises(ValueError):
          pio.to_json(dict1)
  
imports: import plotly.graph_objs
  import plotly.io
  import pytest
  import plotly
  import json
  import os
  import tempfile
  from unittest.mock import MagicMock
  from pathlib import Path
label_desc: Use image node_id 4 for calling a global function with example usage: test_to_json_validate(fig1) without return types