Search code examples
encodingjestjsiterm

Double quotes being encoded in Jest tests


I highly doubt this is a Jest issue, but it's where the issue is popping up, so here goes.

My team is using Jest for tests. Today, I was writing tests, something I hadn't done in a project repo for about a week. When running the tests today, they all failed. I noticed that all the double quotes were being encoded like so:

    Expected value to be (using ===):
      "{\"data\":\"Important data\"}"
    Received:
      "{"data":"Important data"}"

Previously, the tests all ran and passed fine.

For my own sanity, I hopped unto the master branch and ran the tests, only to receive the same result. My teammates have also run the tests on their updated master branches but didn't have any issues.

It appears to be local to my machine. I delete node_modules and package-lock.json, and even re-cloned the entire repository. Unfortunately, I am still having the same issue and I'm not sure where to look. If this issue is remotely familiar to anyone, I'd love to hear suggestions.

Some maybe relevant info:

  • macOS 10.14.6
  • iterm2 (UTF-8 encoding)
  • node 8.10
  • npm 6.11.3
  • jest 24.8.0

Solution

  • Turns out the issue was with Node.js. I had not properly configured AVN to read from .node-version, causing the tests to run using another version of node.