meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
497 stars 117 forks source link

(bug) Text Diff Generation Is Very Slow For Anything More Than A Few Lines #83

Open lots0logs opened 4 years ago

lots0logs commented 4 years ago

Describe the bug This is related to #24 but it's worse than described there. Basically when the snapshots don't match, the test will always timeout (60 seconds). It should not take more than 60 seconds to complete the snapshot when the text content is of reasonable length. Here's an example of content that currently fail because the snapshot command takes more than 60 seconds.

Actual

{
  "tagName": "div",
  "attributes": {
    "class": "et_pb_module et_pb_video et_pb_video_0"
  },
  "childNodes": [
    {
      "nodeName": "#text",
      "nodeValue": "\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t"
    },
    {
      "tagName": "div",
      "attributes": {
        "class": "et_pb_video_box"
      },
      "childNodes": [
        {
          "tagName": "div",
          "attributes": {
            "class": "fluid-width-video-wrapper",
            "style": "padding-top: 56.2963%;"
          },
          "childNodes": [
            {
              "tagName": "iframe",
              "attributes": {
                "title": "Divi. The Ultimate WordPress Theme And Visual Page Builder",
                "src": "https://www.youtube.com/embed/FkQuawiGWUw?feature=oembed",
                "frameborder": "0",
                "allow": "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
                "name": "fitvid0"
              }
            }
          ]
        }
      ]
    },
    {
      "nodeName": "#text",
      "nodeValue": "\n\t\t\t\t\n\t\t\t"
    }
  ]
}

Expected

{
  "attributes": {
    "class": "et_pb_module et_pb_video et_pb_video_0"
  },
  "childNodes": [
    {
      "attributes": {
        "class": "et_pb_video_box"
      },
      "childNodes": [
        {
          "attributes": {
            "class": "fluid-width-video-wrapper",
            "style": "padding-top: 56.2963%;"
          },
          "childNodes": [
            {
              "attributes": {
                "allow": "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
                "frameborder": "0",
                "name": "fitvid0",
                "src": "/embed/FkQuawiGWUw",
                "title": "Divi. The Ultimate WordPress Theme And Visual Page Builder"
              },
              "tagName": "iframe"
            }
          ],
          "tagName": "div"
        }
      ],
      "tagName": "div"
    }
  ],
  "tagName": "div"
}

To Reproduce Steps to reproduce the behavior:

  1. Copy/paste expected into your snapshot file.
  2. Pass actual to matchTextSnapshot() with timeout set to 60 seconds.
  3. Test fails with timeout.

Desktop (please complete the following information):