code: def _to_dict_with_event(cls, test_state):
      
      original_dict, event = test_state.asdict_with_event()
  
      # This line may produce a 'dictionary changed size during iteration' error.
      test_state_dict = data.convert_to_base_types(original_dict)
  
      test_state_dict['execution_uid'] = test_state.execution_uid
      return test_state_dict, event
docs: Process a test state into the format we want to send to the frontend.