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


TypeScript tape.Test类代码示例

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


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

示例1: test

test("Test Get Product - NOT existing vendor and device", async (t: Test) => {
  const device = await getProduct("lolo", "haha").catch((err) => t.pass());
  if (device) {
    return t.end("Fake device was found");
  } else {
    t.end();
  }
});
开发者ID:marcopiraccini,项目名称:usbinfo,代码行数:8,代码来源:test.ts

示例2: prepare

export default function prepare (t: Test, pkg?: Object) {
  dirNumber++
  const dirname = dirNumber.toString()
  const pkgTmpPath = path.join(tmpPath, dirname, 'project')
  mkdirp.sync(pkgTmpPath)
  const json = JSON.stringify(pkg || {})
  fs.writeFileSync(path.join(pkgTmpPath, 'package.json'), json, 'utf-8')
  process.chdir(pkgTmpPath)
  t.pass(`create testing package ${dirname}`)

  const modules = path.join(pkgTmpPath, 'node_modules')
  let cachedStorePath: string
  const project = {
    requireModule (pkgName: string) {
      return require(path.join(modules, pkgName))
    },
    has: async function (pkgName: string) {
      t.ok(await exists(path.join(modules, pkgName)), `${pkgName} is in node_modules`)
    },
    hasNot: async function (pkgName: string) {
      t.ok(!await exists(path.join(modules, pkgName)), `${pkgName} is not in node_modules`)
    },
    getStorePath: async function () {
      if (!cachedStorePath) {
        const modulesYaml = await readModules(modules)
        if (!modulesYaml) {
          throw new Error('Cannot find module store')
        }
        cachedStorePath = modulesYaml.storePath
      }
      return cachedStorePath
    },
    resolve: async function (pkgName: string, version?: string, relativePath?: string) {
      const pkgFolder = version ? path.join('localhost+4873', pkgName, version) : pkgName
      if (relativePath) {
        return path.join(await project.getStorePath(), pkgFolder, relativePath)
      }
      return path.join(await project.getStorePath(), pkgFolder)
    },
    storeHas: async function (pkgName: string, version?: string) {
      t.ok(await exists(await project.resolve(pkgName, version)), `${pkgName}@${version} is in store`)
    },
    storeHasNot: async function (pkgName: string, version?: string) {
      try {
        t.ok(!await exists(await project.resolve(pkgName, version)), `${pkgName}@${version} is not in store`)
      } catch (err) {
        if (err.message === 'Cannot find module store') {
          t.pass(`${pkgName}@${version} is not in store`)
          return
        }
        throw err
      }
    },
    isExecutable: function (pathToExe: string) {
      return isExecutable(t, path.join(modules, pathToExe))
    },
  }
  return project
}
开发者ID:andreypopp,项目名称:pnpm,代码行数:59,代码来源:prepare.ts

示例3: function

 storeHasNot: async function (pkgName: string, version?: string) {
   try {
     t.ok(!await exists(await project.resolve(pkgName, version)), `${pkgName}@${version} is not in store`)
   } catch (err) {
     if (err.message === 'Cannot find module store') {
       t.pass(`${pkgName}@${version} is not in store`)
       return
     }
     throw err
   }
 },
开发者ID:andreypopp,项目名称:pnpm,代码行数:11,代码来源:prepare.ts


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