0

the string looks like this after I did JSON.stringify the whole object

'Error: Expected image to match or be a close match to snapshot but was 0.009980258828690502% different from snapshot (91 differing pixels).\n\u001b[1m\u001b[31mSee diff for details:\u001b[39m\u001b[22m \u001b[31m/src/pages/__image_snapshots__/__diff_output__/register-test-js-register-page-register-automated-desktop-control-1-diff.png\u001b[39m\n at Object.toMatchImageSnapshot (/src/command/getPageImageShot.js:62:25)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:189:7)'

This value does not seems as a result of my json.stringify, as its the value within an object as a string by itself.

I wonder how can I parse out the whole path string (in this case its the path after See diff for details but without all the gibberish in between) from this clumb of mess? and what process produced all the 39m, 22m, u0001b, etc? Is parsing it the best way? Maybe I overlooked some better approach?

I woonder

ey dee ey em
  • 7,991
  • 14
  • 65
  • 121
  • Depending on the consistency of the error messages, you can get the path either with splitting at ':', or regex. (among others) – GitProphet May 14 '19 at 20:56
  • @SimonL yea, I choose that approach as well... but was wonder if there is a "right" way to do it before .ha... – ey dee ey em May 14 '19 at 21:03

0 Answers0