runSerializationTestSuite = (testCases, blockly = Blockly) => {
  /**
   * Creates test callback for xmlToBlock test.
   * @param {!SerializationTestCase} testCase The test case information.
   * @returns {!Function} The test callback.
   */
  const createSerializedDataToBlockTestCallback = (testCase) => {
    return function () {
      let block;
      if (testCase.json) {
        block = blockly.serialization.blocks.append(
          testCase.json,
          this.workspace,
          {recordUndo: true},
        );
      } else {
        block = blockly.Xml.domToBlock(
          blockly.utils.xml.textToDom(testCase.xml),
          this.workspace,
        );
      }
      if (globalThis.clock) globalThis.clock.runAll();
      testCase.assertBlockStructure(block);
    };
  };
  /**
   * Creates test callback for xml round trip test.
   * @param {!SerializationTestCase} testCase The test case information.
   * @returns {!Function} The test callback.
   */
  const createRoundTripTestCallback = (testCase) => {
    return function () {
      if (testCase.json) {
        const block = blockly.serialization.blocks.append(
          testCase.json,
          this.workspace,
          {recordUndo: true},
        );
        if (globalThis.clock) globalThis.clock.runAll();
        const generatedJson = blockly.serialization.blocks.save(block);
        const expectedJson = testCase.expectedJson || testCase.json;
        assert.deepEqual(generatedJson, expectedJson);
      } else {
        const block = blockly.Xml.domToBlock(
          blockly.utils.xml.textToDom(testCase.xml),
          this.workspace,
        );
        if (globalThis.clock) globalThis.clock.runAll();
        const generatedXml = blockly.Xml.domToPrettyText(
          blockly.Xml.blockToDom(block),
        );
        const expectedXml = testCase.expectedXml || testCase.xml;
        assert.equal(generatedXml, expectedXml);
      }
    };
  };
  suite('Serialization', function () {
    suite('append block', function () {
      runTestCases(testCases, createSerializedDataToBlockTestCallback);
    });
    suite('serialization round-trip', function () {
      setup(function () {
        sinon.stub(blockly.utils.idGenerator.TEST_ONLY, 'genUid').returns('1');
      });

      teardown(function () {
        sinon.restore();
      });

      runTestCases(testCases, createRoundTripTestCallback);
    });
  });
}
Runs serialization test suite.
@param {!Array<!SerializationTestCase>} testCases The test cases to run.
@param {?Blockly} blockly The instance of Blockly to use for the
    tests.  Optional, but must be supplied and must correspond to
    the instance used to create this.workspace if that would not
    otherwise be the case.