Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unable to parse child response data #259

Closed
aleclarson opened this issue Feb 17, 2015 · 15 comments · May be fixed by tjenkinson/jest#6, affiliatedkat/jest#3, oudomskn/jest#2, oudomskn/jest#1 or nathang21/jest#1

Comments

@aleclarson
Copy link
Contributor

Has anyone else experienced this error when running jest on their tests? I use Coffeescript and a preprocessor that transpiles to Javascript before testing (not sure if relevant).

Terminal output

Failed with unexpected error.

<rootDir>/node_modules/jest-cli/src/jest.js:179
      throw error;
            ^
Error: Unable to parse child response data: 
<rootDir>/src/modules/__tests__/merge.coffee
{
  "response": {
    "numFailingTests": 0,
    "numPassingTests": 0,
    "testResults": [],
    "logMessages": [],
    "perfStats": {
      "start": 1424210183053,
      "end": 1424210183083
    },
    "testFilePath": "<rootDir>/src/modules/__tests__/merge.coffee",
    "coverage": {}
  }
}

  at Worker._onStdout (<rootDir>/node_modules/jest-cli/node_modules/node-worker-pool/Worker.js:100:9)
  at Socket.emit (events.js:95:17)
  at Socket.<anonymous> (_stream_readable.js:765:14)
  at Socket.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:427:10)
  at emitReadable (_stream_readable.js:423:5)
  at readableAddChunk (_stream_readable.js:166:9)
  at Socket.Readable.push (_stream_readable.js:128:10)
  at Pipe.onread (net.js:529:21)

It has nothing to do with the __tests__/merge.coffee code; I remove it and the error persisted.

What's the solution here? :octocat:

@mattnorris
Copy link

👍

@aleclarson
Copy link
Contributor Author

I think I solved it by using Node v0.10.36 and Jest v0.2.2 instead of v0.12.0 and v0.3.0 respectively.

@parecementeria
Copy link

Same problem for me, I've tried with Node v0.10.36 and Jest v0.2.2 but still not working

<rootDir>/node_modules/jest-cli/src/jest.js:179
      throw error;
            ^
Error: Unable to parse child response data: 
preprocessor.js
{
  "response": {
    "numFailingTests": 0,
    "numPassingTests": 0,
    "testResults": [],
    "logMessages": [],
    "perfStats": {
      "start": 1424710573530,
      "end": 1424710573588
    },
    "testFilePath": "<rootDir>/js/components/__tests__/contactInfo-test.js",
    "coverage": {}
  }
}

  at Worker._onStdout (<rootDir>/node_modules/jest-cli/node_modules/node-worker-pool/Worker.js:100:9)
  at Socket.emit (events.js:95:17)
  at Socket.<anonymous> (_stream_readable.js:765:14)
  at Socket.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:427:10)
  at emitReadable (_stream_readable.js:423:5)
  at readableAddChunk (_stream_readable.js:166:9)
  at Socket.Readable.push (_stream_readable.js:128:10)
  at Pipe.onread (net.js:529:21)

@ninjapanzer
Copy link

This happens for me when I have more than one test file. If I have one test file with multiple test everything is fine but if I move a test into a new file with a describe block things fail. Here is a gist of my 2 test https://gist.github.com/ninjapanzer/f6151ec909afe72b271f

@drd
Copy link

drd commented Apr 7, 2015

I was getting this error as well, but only while I was debugging some babel-compiled jsx/es6 files. As soon as I stopped console.log'ing to stdout, the problem went away. Maybe check to see if you're inadvertently writing to stdout?

@hulufei
Copy link

hulufei commented Apr 15, 2015

Same for me when have more than one test files.

node v0.10.38
Jest 0.4

@anyong
Copy link

anyong commented Apr 27, 2015

I have been having some interesting issues trying to get jest set up, and just ran in to this one. I was having the issue described here: https://gist.github.com/anonymous/ac700b7968b432057088

Then I made another test file to try something different, and ended up with the result in this thread. @drd removing console.log from my preprocessor.js fixed the problem mentioned here, but now both of my files are giving me the same error as the above gist.

Jest seems really buggy...

@HeikkiNaski
Copy link

I also encountered this. It only happened when using several files and when I had configured setupTestFrameworkScriptFile which had this line:

jasmine.VERBOSE = true;

Command: jest spec-1.js spec-2.js

Error message:   Error: Unable to parse child response data:
logging:  >> Jasmine waiting for success callback should be called
logging:  >> Jasmine waiting for success callback should be called

Versions:
jest --version
v0.4.

node --version
v0.10.24

babel-node --version
5.1.2

package.json

  "jest": {
    "testDirectoryName": "test",
    "scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
    "unmockedModulePathPatterns": [
      "./*"
    ],
    "testFileExtensions": [
      "es6",
      "js"
    ],
    "moduleFileExtensions": [
      "js",
      "json",
      "es6"
    ],
    "setupTestFrameworkScriptFile": "test/jasmine.rc"
  }

@whroman
Copy link

whroman commented Jun 1, 2015

@drd Thanks! That worked!

@element6
Copy link
Contributor

I had the same issue. It turns out to be the 'morgan' middleware. I didn't dig into morgan, just used NODE_ENV=test to bypass it when running tests.

if (process.env.NODE_ENV != 'test') {
  app.use(logger('dev'));
}

@ehacke
Copy link

ehacke commented Sep 13, 2015

I had a similar problem caused by my bunyan logger writing to stdout.

Seems a little brittle to break the test framework if something writes to stdout.

console.log seems to work inside the test cases.

But if I try to use bunyan logging, the log messages either don't appear, or break the framework with the response 'Unable to parse child response data'.

@thekarel
Copy link
Contributor

I ran into this issue when using pit and jasmine.VERBOSE = true. pit is in the 3rd test:

Error: Unable to parse child response data:
logging:  >> Jasmine waiting for something to happen
logging:  >> Jasmine waiting for something to happen
{
  "response": {
    "numFailingTests": 0,
    "numPassingTests": 3,
    "testResults": [
      {
        "title": "it calls WebAPIUtils.fetchConfig",
        "ancestorTitles": [
          "ServerActions",
          "fetchConfig"
        ],
        "failureMessages": [],
        "logMessages": [],
        "numPassingAsserts": 1
      },
      {
        "title": "it returns a promise",
        "ancestorTitles": [
          "ServerActions",
          "fetchConfig"
        ],
        "failureMessages": [],
        "logMessages": [],
        "numPassingAsserts": 1
      },
      {
        "title": "it resolves when WebAPIUtils.fetchConfig resolves",
        "ancestorTitles": [
          "ServerActions",
          "fetchConfig"
        ],
        "failureMessages": [],
        "logMessages": [],
        "numPassingAsserts": 1
      }
    ],
    "logMessages": [],
    "perfStats": {
      "start": 1442574427937,
      "end": 1442574429939
    },
    "testFilePath": "/.../ServerActions.test.js",
    "coverage": {}
  }
}

Removing pit or setting jasmine.VERBOSE = false allows the tests to run.

@Pajn
Copy link
Contributor

Pajn commented Sep 26, 2015

Feels like a timings issue or some kind of race condition.
Happens usually if doing console.log and happens randomly on Travis when the same works offline (and usually works if I rerun Travis)

@amasad
Copy link
Contributor

amasad commented Oct 7, 2015

Should be fixed via #540 (will go out with version 0.6). Please reopen if that's not the case.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.