Javascript 吞咽单独工作但不在观察模式下的任务
我正在开发一个运行在node.js上的CLI工具。我正在尝试为tdd设置环境,但我很难用gulp来完成 我所有的“独立”任务都是从gulp工作中完成的。 这是: 生成任务: 测试任务: 如您所见,我有一个任务,将我的typescript文件构建到与es5兼容的js中。还有另一个任务,它使用先例构建运行我的测试 如果我一个人管理他们。它起作用了 我已尝试添加手表模式: 构建:观看: 测试:手表: 建造:手表工作。每次编辑typescript文件时,都会触发生成任务并重新生成项目。这在这里并不重要,因为测试任务触发构建。这只是说,这种手表模式的工作 测试:手表坏了。第一次迭代由任务依赖项触发,但在编辑typescript文件或测试文件时,出现以下错误:Javascript 吞咽单独工作但不在观察模式下的任务,javascript,typescript,gulp,mocha.js,gulp-watch,Javascript,Typescript,Gulp,Mocha.js,Gulp Watch,我正在开发一个运行在node.js上的CLI工具。我正在尝试为tdd设置环境,但我很难用gulp来完成 我所有的“独立”任务都是从gulp工作中完成的。 这是: 生成任务: 测试任务: 如您所见,我有一个任务,将我的typescript文件构建到与es5兼容的js中。还有另一个任务,它使用先例构建运行我的测试 如果我一个人管理他们。它起作用了 我已尝试添加手表模式: 构建:观看: 测试:手表: 建造:手表工作。每次编辑typescript文件时,都会触发生成任务并重新生成项目。这在这里并不重要,
{ [TypeError: Cannot read property 'defaultEncoding' of undefined]
domain:
{ domain: null,
_events: { error: [Function: handleException] },
_maxListeners: undefined,
members: [] },
domainThrown: true,
name: 'TypeError',
message: 'Cannot read property \'defaultEncoding\' of undefined',
stack: 'TypeError: Cannot read property \'defaultEncoding\' of undefined\n at DestroyableTransform.Writable.write (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:186:21)\n at Glob.<anonymous> (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/index.js:44:14)\n at Glob.emit (events.js:107:17)\n at Glob._emitMatch (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:457:8)\n at Glob._processReaddir2 (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:405:12)\n at /Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:345:17\n at RES (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/node_modules/inflight/inflight.js:23:14)\n at /Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/node_modules/inflight/inflight.js:30:13\n at process._tickDomainCallback (node.js:381:11)',
showStack: true,
showProperties: true,
plugin: 'gulp-mocha' }
你有什么建议吗?好的,我发现了问题所在 我在单元测试中使用mockry,但在一些测试之后忘记禁用它。我只需添加我的测试文件:
afterEach(function() {
mockery.disable();
});
祝你今天愉快。
托马斯
gulp.task('build:watch', ['build'], function() {
gulp.watch([
PATHS.lib + '/**/*.ts'
], ['build']);
});
gulp.task('test:watch', ['test'], function () {
gulp.watch([
PATHS.lib + '/**/*.ts',
PATHS.test + '/**/*.js'
], ['test']);
});
{ [TypeError: Cannot read property 'defaultEncoding' of undefined]
domain:
{ domain: null,
_events: { error: [Function: handleException] },
_maxListeners: undefined,
members: [] },
domainThrown: true,
name: 'TypeError',
message: 'Cannot read property \'defaultEncoding\' of undefined',
stack: 'TypeError: Cannot read property \'defaultEncoding\' of undefined\n at DestroyableTransform.Writable.write (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:186:21)\n at Glob.<anonymous> (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/index.js:44:14)\n at Glob.emit (events.js:107:17)\n at Glob._emitMatch (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:457:8)\n at Glob._processReaddir2 (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:405:12)\n at /Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/glob.js:345:17\n at RES (/Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/node_modules/inflight/inflight.js:23:14)\n at /Users/thomashourlier/Documents/Work/jsProjects/hawker/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob/node_modules/inflight/inflight.js:30:13\n at process._tickDomainCallback (node.js:381:11)',
showStack: true,
showProperties: true,
plugin: 'gulp-mocha' }
[10:58:24] Using gulpfile ~/Documents/Work/jsProjects/hawker/gulpfile.js
[10:58:24] Starting 'build'...
[10:58:25] Finished 'build' after 1.01 s
[10:58:25] Starting 'test'...
Hawker
✓ should get the Logger
✓ should get the Parser
✓ should define a file loader
✓ should define a url loader
✓ should launch hawker
FileLoader
✓ should be defined
✓ should get a configuration file
Parser
✓ should be defined
✓ should parse configuration file
9 passing (24ms)
[10:58:26] Finished 'test' after 98 ms
[10:58:26] Starting 'test:watch'...
[10:58:26] Finished 'test:watch' after 14 ms
[10:58:28] Starting 'build'...
[10:58:28] { [TypeError: Cannot read property 'defaultEncoding' of undefined] ...
afterEach(function() {
mockery.disable();
});