當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。