本文整理汇总了TypeScript中tape.Test.pass方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Test.pass方法的具体用法?TypeScript Test.pass怎么用?TypeScript Test.pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tape.Test
的用法示例。
在下文中一共展示了Test.pass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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
}
示例2: 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
}
},
示例3: getVendor
const device = await getVendor("xxxxx").catch((err) => t.pass());
示例4: getProduct
const device = await getProduct("lolo", "haha").catch((err) => t.pass());