5

I'm using IO.js 1.4.3 and Jest to run my test suites. I need a newer version of V8 because I am using ES6 features like Promises.

If I try the simplest possible test:

describe('the truth', function() {
    it('is true', function() {
        expect(true).toBeTruthy();
    });
});

it works (thankfully). If I include, however, a call to require() (which I have to do to test my own code), I get:

Using Jest CLI v0.4.0
Waiting on 1 test...Segmentation fault: 11

This happens irrespective of which module I include, and whether I make a call to jest.dontMock() first.

This doesn't really tell me very much qua error message, and require really does seem to be the problem. Are there any solutions to this other than reverting to pre-1.0 node.js?

GTF
  • 8,031
  • 5
  • 36
  • 59
  • Can you make an example git repo to demonstrate the bug? `Segmentation fault` errors are tough to track down, especially since this could be happening for several reasons. – loganfsmyth Mar 07 '15 at 00:36
  • I've discovered that this error seems to be directly related to using a higher node version. Rolling back to v0.10.38 makes Jest work, but I don't really know why that is. – GTF Apr 20 '15 at 08:56

2 Answers2

2

This happens in cases where you have installed node_modules using node at some version, and then later switching to iojs using nvm install iojs and trying to run the installed node_modules with npm. It isn't likely that this is your issue, but hopefully anyone else googling around can try this and fix it.

nvm install iojs
rm -rf node_modules
npm install

then running whatever it is you're trying to run, usually something like npm run start.

Liam Horne
  • 857
  • 1
  • 7
  • 15
  • You're right that this wasn't my issue, I'd already tried rebuilding my node modules. Luckily it's been fixed in some of the Jest deps. – GTF Aug 29 '15 at 23:39
0

Segmentation faults almost always come from native C++ code, since JS cannot cause such crashes unless it triggers a V8 bug. As such, I'd suspect the issue is with the contextify native module that jest indirectly depends on (via jsdom).

It might be worth trying to hack together a version of jest that depends on the latest jsdom, which no longer has a native module dependency.

Domenic
  • 110,262
  • 41
  • 219
  • 271
  • It started working with later versions of IO.js. There's some discussion in various Jest issues on this but it seems largely unresolved. – GTF May 19 '15 at 21:31