LoginSignup
3
0

More than 5 years have passed since last update.

Jestのテスト実行時に”Cannot read property 'pipe' of undefined”エラー

Last updated at Posted at 2015-03-07

発生した問題

Jestを使って書いたテストコードを実行するために、npm testを実行すると以下のエラーが発生した。

/Users/Foo/Projects/Bar/node_modules/jest-cli/node_modules/harmonize/harmonize.js:31
        node.stdout.pipe(process.stdout);
                   ^
TypeError: Cannot read property 'pipe' of undefined
    at module.exports (/Users/Foo/Projects/Bar/node_modules/jest-cli/node_modules/harmonize/harmonize.js:31:20)
    at Object.<anonymous> (/Users/Foo/Projects/Bar/node_modules/jest-cli/bin/jest.js:39:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
npm ERR! Test failed.  See above for more details.

原因

事項環境にインストールされていたNode.jsのバージョンが0.12.x系で、Jestがまだ対応できていないバージョンだった。(2015/3/7現在)

解決

Node.jsのバージョンを0.10.x系に変更し、npm installからやり直すことで解決。無事にテストが実行できた。

ちなみに、0.11.x系のバージョンの最新版ではうまく動かなかった。それ以上は調べてない。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0