小编Ahm*_*oub的帖子

如何断言函数调用顺序

我用jest.fn模拟了两个函数:

let first = jest.fn();
let second = jest.fn();
Run Code Online (Sandbox Code Playgroud)

我如何断言first之前调用过second

我正在寻找类似于sinon的 .calledBefore断言。

更新 我使用了这种简单的“临时”解决方法

it( 'should run all provided function in order', () => {

  // we are using this as simple solution
  // and asked this question here /sf/ask/3224637531/

  let excutionOrders = [];
  let processingFn1  = jest.fn( () => excutionOrders.push( 1 ) );
  let processingFn2  = jest.fn( () => excutionOrders.push( 2 ) );
  let processingFn3  = jest.fn( () => excutionOrders.push( 3 ) ); …
Run Code Online (Sandbox Code Playgroud)

testing jestjs babel-jest

5
推荐指数
2
解决办法
1783
查看次数

WebStorm无法将live.json识别为json文件

当json文件命名时live.json,WebStorm不对json文件应用json格式/颜色突出显示,任何其他名称都可以正常工作.

我正在使用WebStorm 2016.2.4 Build#WS-162.2228.20,建于2016年10月18日

有什么建议?

intellij-idea webstorm

3
推荐指数
1
解决办法
918
查看次数

标签 统计

babel-jest ×1

intellij-idea ×1

jestjs ×1

testing ×1

webstorm ×1