用于jestjs的npm脚本

时间:2015-08-04 18:53:15

标签: node.js npm jestjs

我正在尝试使用jestjs进行测试,但我很难这样做。

当我运行此命令时:

npm testj

npm说我没有那个剧本:

$ npm testj

Usage: npm <command>

where <command> is one of:
    access, add-user, ....

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm faq          commonly asked questions
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /Users/bli1/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@2.13.1 /usr/local/lib/node_modules/npm

我的package.json

{
  ...
  ...
  "scripts": {
   ...
   ...
   "testj": "jest"
   ...
  },
  "dependencies": {
    ...
    ...
    "react": "^0.13.1",
    "react-highlight": "^0.4.1",
    "react-router": "^0.13.2",
    "react-select": "^0.5.6",    
  },
  "devDependencies": {
    ...
    ...
    "jest-cli": "^0.4.14",
    "react-tools": "^0.13.1",
  }
  "jest": {
    "scriptPreprocessor": "<rootDir>/preprocessor.js",
    "unmockedModulePathPatterns": [
      "<rootDir>/node_modules/react"
    ]
  }
}

preprocessor.js

var ReactTools = require('react-tools');

module.exports = {
    process: function(src) {
        return ReactTools.transform(src);
    }
};

1 个答案:

答案 0 :(得分:2)

也许你需要npm run testj

只有少数脚本有速记,例如npm testhttps://docs.npmjs.com/misc/scripts

相关问题