当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lab.script函数代码示例

本文整理汇总了TypeScript中lab.script函数的典型用法代码示例。如果您正苦于以下问题:TypeScript script函数的具体用法?TypeScript script怎么用?TypeScript script使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了script函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: require

/// <reference path="../../typings/index.d.ts" />
const Code = require('code');   // assertion library
const Lab = require('lab');
const lab = exports.lab = Lab.script();
const Hapi = require('hapi');

const env = process.env.env;
delete process.env.env;
import server from "../../src/server";

const expect = Code.expect;

lab.describe('misc/routesTest.ts', function () {

  lab.it('returns the response result', (done) => {

    server.inject('/', function (res) {
      expect(res.statusCode).to.equal(404);
      process.env.env = env;
      done();
    });

  });

});
开发者ID:divramod,项目名称:hapi-seed-advanced,代码行数:25,代码来源:serverEnvTest.ts

示例2: script

import { script, assertions } from "lab";

const { experiment, describe, suite, test, it, before, beforeEach, after, afterEach } = script();
const expect = assertions.expect;
const fail = assertions.fail;

experiment('math', () => {

    before((done) => {

        setTimeout(() => {

            done();
        }, 1000);
    });

    beforeEach((done) => {

        done();
    });

    test('returns true when 1 + 1 equals 2', (done) => {

        expect(1 + 1).to.equal(2);
        done();
    });
});

experiment('math', () => {

    before(() => {
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:lab-tests.ts

示例3: script

import { expect, fail } from 'code';
import { script } from 'lab';
export const lab = script();

import { IHaveVersion, loadPackageMetadataSync } from '../src';

lab.experiment('loadPackageMetadataSync result', () => {
    let metadata: IHaveVersion;

    lab.before(done => {
        metadata = loadPackageMetadataSync();
        done();
    });

    lab.test('is an object with name and version', done => {
        expect(metadata).to.be.an.object()
            .and.contain([ 'name', 'version' ]);
        done();
    })

    lab.test('has correct .name', done => {
        expect(metadata.name, 'name').to.equal('lab-coverage-vs-sourcemaps-typescript-edition');
        done();
    })

    lab.test('has correct .version', done => {
        // The transpiled output for this file is 28 lines long.
        // 'npm run fail' correctly reports a failure in line 30: 
        const expectedVersion = process.env.BAD_VERSION || '1.0.0';
        expect(metadata.version, 'version').to.equal(expectedVersion);
        done();
开发者ID:garthk,项目名称:lab-coverage-vs-sourcemaps-typescript-edition,代码行数:31,代码来源:test-it.ts

示例4: script

import { expect, fail } from 'code';
import { script } from 'lab';
export const lab = script({
    cli: {
        // Overriding the command line options is more useful to force
        // necessary functionality, e.g. globals skipping or source maps.
        globals: ['leakedButOK'],

        // The transpiler won't follow reference paths or look up
        // the typings in `typings-local`, despite `typeRoots`, so we
        // have to resolve this `const enum` ourselves:
        progress: 2, // ProgressReporting.Verbose,

        // If you don't specify sourcemaps on the `lab` command line or in
        // your `lab.script`, the line numbers on your errors will be wrong.
        // `lab-transform-typescript` will enable inline source maps for
        // the transpiler.
        sourcemaps: true,
    }
});

(global as any)['leakedButOK'] = true;

const debug = require('debug')('lab-transform-typescript:test');

lab.experiment('experiment', () => {
    lab.before(done => {
        debug('callback before all');
        done();
    });
开发者ID:garthk,项目名称:lab-transform-typescript,代码行数:30,代码来源:demo.ts


注:本文中的lab.script函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。