本文整理汇总了TypeScript中mocha.afterEach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript afterEach函数的具体用法?TypeScript afterEach怎么用?TypeScript afterEach使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了afterEach函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('TypeScript Usage', function() {
beforeEach(function() {
this.server = new Pretender();
});
afterEach(function() {
this.server.shutdown();
});
describe('generics in HTTP methods', function() {
describe('request', function() {
beforeEach(function() {
this.server.get('/users/1', () => jsonResponse(200, { name: 'Alex' }));
});
it('works without the generic defined', async function() {
const ajax = new AjaxRequest();
const response = await ajax.request('/users/1');
expect(response).to.deep.equal({ name: 'Alex' });
});
it('can provide a generic type to resolve to', async function() {
const ajax = new AjaxRequest();
const response = await ajax.request<User>('/users/1');
expect(response).to.deep.equal({ name: 'Alex' });
});
});
});
it('types the injected service', function() {
Service.extend({
ajax: service('ajax'),
makeRequest<T>(url: string) {
return this.get('ajax').request<T>(url);
}
});
});
});
示例2: describeModule
describeModule('component:x-foo', 'TestModule callbacks', function() {
before(function() {
class I18n extends Ember.Object {}
this.skip();
this.timeout(1000);
this.registry.register('helper:i18n', I18n);
this.registry.register('helper:i18n', I18n, { singleton: true });
this.register('service:i18n', {});
this.inject.service('i18n');
this.inject.service('i18n', { as: 'i18n' });
this.factory('object:user').create();
});
after(function() {
});
beforeEach(function() {
});
afterEach(function() {
});
});