简体   繁体   English

TDD with reactjs,reactify,babelify,browserify,gulp

[英]TDD with reactjs, reactify, babelify, browserify, gulp

I am looking for running test on a project which use : 我正在寻找一个项目的运行测试,该项目使用:

  • browserify with these transform : 使用这些转换进行浏览
    • babelify babelify
    • reactify reactify

I did try the combo JSDOM + Mocha but testing a component which has not been builded yet will fail on require call from a component to another : 我确实尝试过组合JSDOM + Mocha,但测试一个尚未构建的组件,但是在从组件到另一个组件的需要调用时将失败:

> mocha --compilers js:babel/register --recursive

module.js:338
    throw err;
    ^
Error: Cannot find module 'system/services/AuthService'

I think I need to run mocha test during the gulp build watchify and build tasks. 我认为我需要在gulp构建watchify和构建任务期间运行mocha测试。 I am not sure if handling the test during the build process is a good option. 我不确定在构建过程中处理测试是否是一个不错的选择。

Normaly, after a successful build I have a file in client/build/js/bundle.js in ES5. Normaly,在成功构建之后,我在ES5中的client/build/js/bundle.js中有一个文件。

I want to be able to test my component using the ES6 file which require a browserify for being readble by my testing lib. 我希望能够使用ES6文件测试我的组件,该文件需要一个browserify才能被我的测试库读取。

Does anyone could provide me a good option, with some npm modules or anything that could help me achieve TDD in my environment ? 有没有人可以提供一个很好的选择,有一些npm模块或任何可以帮助我在我的环境中实现TDD的东西?

Maybe Mochify is a good fit for your use case. 也许Mochify非常适合您的用例。 Here's a React example: https://github.com/mantoni/mochify.js/wiki/Testing-a-ReactJS-Component-with-Mochify 这是一个React示例: https//github.com/mantoni/mochify.js/wiki/Testing-a-ReactJS-Component-with-Mochify

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM