Jest: After install with yarn and execute npm t, TypeError: config[key].map is not a function

Created on 19 Oct 2016  路  2Comments  路  Source: facebook/jest

Do you want to request a _feature_ or report a _bug_?
Report a BUG

What is the current behavior?

TypeError: config[key].map is not a function
    at /Projects/tmp/happy-number-meetup/node_modules/jest-config/build/normalize.js:311:29
    at Array.reduce (native)
    at normalize (/Projects/tmp/happy-number-meetup/node_modules/jest-config/build/normalize.js:295:23)
    at /Projects/tmp/happy-number-meetup/node_modules/jest-config/build/loadFromPackage.js:24:12

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

https://gitlab.com/ridermansb/happy-number-meetup/tree/master

Just clone, npm install and execute npm t

What is the expected behavior?
Execute the test :)

Run Jest again with --debug and provide the full configuration it prints. Please mention your node and npm version and operating system.

> jest --debug

TypeError: config[key].map is not a function
    at /Projects/tmp/happy-number-meetup/node_modules/jest-config/build/normalize.js:311:29
    at Array.reduce (native)
    at normalize (/Projects/tmp/happy-number-meetup/node_modules/jest-config/build/normalize.js:295:23)
    at /Projects/tmp/happy-number-meetup/node_modules/jest-config/build/loadFromPackage.js:24:12

npm ERR! Darwin 16.0.0
npm ERR! argv "/.nvm/versions/node/v5.12.0/bin/node" ".nvm/versions/node/v5.12.0/bin/npm" "run" "test" "--"
npm ERR! node v5.12.0
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `jest --debug`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test script 'jest --debug'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the happy-number-meetup package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     jest --debug
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs happy-number-meetup
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls happy-number-meetup
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Projects/tmp/happy-number-meetup/npm-debug.log

Most helpful comment

If someone else has this issue - this is what worked for me:
I had a configuration like this:
{ "testPathDirs": "../path/" }

But if you look close into the config documentation, you see that "testPathDirs" expects an ARRAY with strings. So this worked for me:

{ "testPathDirs": ["../path/"] }

If testPathDirs is not the property causing issues for you, take a look at the documentation and make sure you're following the rules.

All 2 comments

Forget.. I fixed change the config ... "testRegex": "/.+-test\\.js$/gmi",

If someone else has this issue - this is what worked for me:
I had a configuration like this:
{ "testPathDirs": "../path/" }

But if you look close into the config documentation, you see that "testPathDirs" expects an ARRAY with strings. So this worked for me:

{ "testPathDirs": ["../path/"] }

If testPathDirs is not the property causing issues for you, take a look at the documentation and make sure you're following the rules.

Was this page helpful?
0 / 5 - 0 ratings