我不太确定,也许我错过了一些明显的东西,但我不知道如何链接两个承诺。
我的基于回调的代码看起来像这样:
async.series([
function (cb) {
// Create the directory if the nodir switch isn't on
if (!nodir) {
fs.mkdir('somedirectory', function (err) {
if (err) {
log('error while trying to create the directory:\n\t %s', err)
process.exit(0)
}
log('successfully created directory at %s/somedirectory', process.cwd())
cb(null)
})
}
cb(null)
},
function (cb) {
// Get the contents of the sample YML
fs.readFile(path.dirname(__dirname) + '/util/sample_config.yml', function (err, c) {
var sampleContent = c
if (err) {
log('error while reading the sample file:\n\t %s', …Run Code Online (Sandbox Code Playgroud) 如果我有一个抛出错误的函数并且我想测试该错误,我会写这样的东西:
test('throws at something that is not a string', t => {
t.plan(1)
t.err(loadString(9))
})
Run Code Online (Sandbox Code Playgroud)
但这总是导致执行时来自函数的实际错误:
还有的在not ok 1 no plan found和not ok 2 no assertions found,这也是奇怪的.我怎样才能确定它实际上没有扔?
我的朋友正在使用($ document).on他的CoffeeScript代码.这与通常的不同$(document).on,如果是这样,以什么方式?
javascript ×2
node.js ×2
bluebird ×1
coffeescript ×1
domdocument ×1
fs ×1
jquery ×1
node.js-tape ×1
promise ×1
tap ×1
testing ×1