推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
Flands

jest 中如何 mock 类其中的部分函数?

  •  1
     
  •   Flands · Jan 25, 2021 · 2263 views
    This topic created in 1938 days ago, the information mentioned may be changed or developed.
    import { Recorder, Pubsub } from "trident";
    const pubsub = new Pubsub();
    
    export class SmartRecorder extends Recorder {
      constructor(props) {
        super(props);
      }
      start() {
        pubsub.subscribe('androidData', androidDataHandler);
        return super.start();
      }
    }
    

    使用 mockImplementation 方式,提示 类型“typeof Recorder”上不存在属性“mockImplementation” 使用 jest.requireActual,直接没法运行

    试了两天搜了很多方法都不行,请问下大佬们怎么编写啊?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3775 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:42 · PVG 12:42 · LAX 21:42 · JFK 00:42
    ♥ Do have faith in what you're doing.