本文整理汇总了TypeScript中ava.test.afterEach方法的典型用法代码示例。如果您正苦于以下问题:TypeScript test.afterEach方法的具体用法?TypeScript test.afterEach怎么用?TypeScript test.afterEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ava.test
的用法示例。
在下文中一共展示了test.afterEach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: helper
import * as mst from "mobx-state-tree"
import { test } from "ava"
import * as sinon from "sinon"
import { simpleActionLogger } from "../src"
test.beforeEach(t => {
t.context.log = console.log
console.log = sinon.spy()
})
test.afterEach(t => {
console.log = t.context.log
})
test("it logs", t => {
const Todo = mst.types
.model({
title: ""
})
.actions(self => ({
helper() {},
setTitle(newTitle) {
;(self as any).helper() // should not be logged
self.title = newTitle
}
}))
const Store = mst.types.model({
todos: mst.types.array(Todo)
})
示例2: require
import { test } from 'ava';
const sinon = require('sinon'); // Require because this package does not support commonjs modules
import { Loader } from './loader';
let server;
test.beforeEach(t => {
t.context.loader = new Loader();
server = sinon.fakeServer.create();
});
test.afterEach(() => {
server.restore();
});
// Method Checking
test('should be defined', t => {
t.truthy(t.context.loader);
});
test('should have a method load', t => {
t.truthy(t.context.loader.load);
});
// load(url)
test('load should properly load a json file', t => {
let valid = { KEY: 'value' };
t.context.loader.load('/valid.json').then(result => {
t.deepEqual(result, valid);