本文整理汇总了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();
});
});
});
示例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(() => {
示例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();
示例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();
});