Code Monkey home page Code Monkey logo

akatsuki's People

Contributors

muyunyun avatar

Watchers

 avatar  avatar

akatsuki's Issues

在 TypeScript 中使用 react

export interface Props {
  name: string;
}

class Hello extends React.Component<Props, State> { // 这里为 TS 里类的语法
  render() {
    return (
        ...
    );
  }
}
<Hello name="world" />

测试库比较

和 React 相关的测试库

  • Test Renderer: 官方提供的 React 渲染库,不依赖 UI,纯 JavaScript 对象;
  • Test Utilities: 官方提供的测试工具库;
  • enzyme: 基于 Test Utilities 的封装,更易使用;

Jest 与 Mocha 的比较

Jest 各个功能封装得比较全面,类似 express;
Mocha 给的自由度更高,需自行搭配其它库,类似 koa;

需要操作 UI 的时候,有两个概念 1.mock(spy) 和 2.单一 dom。

  • mock: 可以理解成监视函数,可以用来判断执行某个事件时候该函数是否执行;
  • 单一 dom: Jest 已经集成了这个单一 dom 这个条件,mocha 需要配合 jsdom 来使用;

和 mocha 搭配的库

  • jsdom: 控制台的浏览器环境;
  • chai: 搭配 mocha 使用的断言库;
  • chai-spies: 同上述 mock;

测试方式

  • BDD(Behaviour Driven Development): should/expect
  • TDD(Test Driven Development): assert

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.