Tag: jestjs

与coffeescript jsx的Jest?

如何使用Jesttesting用CoffeeScript + React jsx编写的React组件? Jest提供的唯一的CoffeeScript示例使用普通的CoffeeScript,并且不能与CoffeeScript + React JSX一起工作(语法错误达到< )。 我曾经尝试过 第一次尝试:execSync // preprocessor.js var execSync = require('exec-sync'); module.exports = { process: function (src, path) { return execSync('browserify -t coffee-reactify ' + path); } }; 这工作,但需要太多的时间(虚拟testing12秒)。 然后我试着: 第二次尝试:咖啡反应变换 // preprocessor.js var coffee = require('coffee-script'); var transform = require('coffee-react-transform'); module.exports = { process: function(src, path) { if […]

从'ReactDebugTool.js'找不到模块'react / lib / ReactComponentTreeHook'

我试图让Jest运行我的React应用程序的快照testing。 我的package.json版本: "react": "15.6.1", "react-dom": "15.6.1", "react-test-renderer": "15.6.1", 我无法通过这个错误: ● Test suite failed to run Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js' at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17) at Object.<anonymous> (node_modules/react-test-renderer/lib/ReactDebugTool.js:16:30) 我已经尝试删除并重新安装我的node_modules目录,我已经validation,我的组件的path是正确的,但仍然得到这个相同的错误。 我的testing看起来像这样: import React from 'react'; import renderer from 'react-test-renderer'; import { Section } from '../../app/views/containers/section'; it('renders correctly', () => { const section = renderer.create( <Section key="1" section="finance"/> […]

如何使用Jesttesting单个文件?

我能够使用Jesttesting多个文件,但我无法弄清楚如何testing一个文件。 我有: 运行npm install jest-cli –save-dev 更新了package.json :`{…“scripts”:{“test”:“jest”} …} 写了一些testing。 运行npm test按预期工作(目前它运行14个testing)。 如何testing单个文件,例如testingapp/foo/__tests__/bar.spec.js ? 我试着运行npm test app/foo/__tests__/bar.spec.js (来自项目根目录),但是我得到以下错误: npm ERR! Error: ENOENT, open '<path to project>/node_modules/app/foo/__tests__/bar.spec.js/package.json' 谢谢