How to use importXML in Jest test?

Hello everyone.
Im trying to test my diagram. Firstly i m creating modeler, all is ok.
Then i`m trying to importXml. it is importing correctly and test passing, but throw errors.
How can i avoid these errors?

it('test2', async () => {
    try {
      const modeler = await createModeler();
      await modeler.importXML(diagram);
      const elementRegistry = modeler.get("elementRegistry"); //correct
    } catch(e) {


export default async function createModeler() { 
  const moddleExtension = {
    name: "Example",
    uri: "http://some-company/schema/example",
    prefix: "example",
    xml: {
      tagAlias: "lowerCase"
    types: [
        name: "ExampleExtensionElement",
        superClass: ["Element"],
        properties: []

  const container = document.createElement('div');
  return new Modeler({
    keyboard: {
      bindTo: document
    moddleExtensions: {
      example: moddleExtension


const diagram = `
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="" xmlns:bpmn="" xmlns:bpmndi="" xmlns:dc="" id="Definitions_1" targetNamespace="">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:endEvent id="Event_1e4r1n0">
      <bpmn:messageEventDefinition id="MessageEventDefinition_18sdth1"/>
  <bpmn:message id="Message_09hbj5k" name="Message2j5q0bc"/>
  <bpmn:message id="Message_126wl3a" name="Message188v4vj"/>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="Event_0hgrms0_di" bpmnElement="Event_1e4r1n0">
        <dc:Bounds x="372" y="212" width="36" height="36"/>

export default diagram;

Pls help, I can’t understand why the error occurs, but the diagram is imported correctly

First of all, what environment are you running the tests in? bpmn-js only works in a browser (e.g. Chrome) but not outside of one (e.g. Node.js).

can bpmn-js fully work in jsdom environment?

I haven’t tried that. What’s wrong with using a headless browser?