1
我的測試代碼對象#<Object>有沒有方法「類型」
var strategy = require('../lib');
var should = require("should");
describe('passport-twitter', function() {
it('should export Strategy constructor directly from package', function() {
console.log('strategy is',strategy);
strategy.should.have.type('function');
});
it('should export Strategy constructor', function() {
strategy.Strategy.should.have.type('function');
});
});
,當我運行此test.it是給我錯誤
1) passport-twitter should export Strategy constructor directly from package:
TypeError: Object #<Object> has no method 'type'
at Context.<anonymous> (/home/ritesh/projects/passport-topcoder/test/module.test.js:7:26)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:211:32)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:358:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:404:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:284:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:293:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:237:23)
at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:261:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
2) passport-twitter should export Strategy constructor:
TypeError: Object #<Object> has no method 'type'
at Context.<anonymous> (/home/ritesh/projects/passport-topcoder/test/module.test.js:11:35)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:211:32)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:358:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:404:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:284:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:293:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:237:23)
at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:261:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
但在文件中指定類型的方法如何擺脫這個錯誤。請幫助一下。
,而不是這個當我嘗試運行
AA
var strategy = require('..');
var should = require("should");
describe('passport-twitter', function() {
it('should export', function() {
console.log('strategy is',strategy);
'xxxx'.should.have.type('function');
});
});
還是我得到的錯誤
1) passport-twitter should export:
TypeError: Object #<Object> has no method 'type'
at Context.<anonymous> (/home/ritesh/projects/passport-topcoder/test/module.test.js:7:23)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:211:32)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:358:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:404:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:284:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:293:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:237:23)
at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:261:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
它是不知道你需要什麼到戰略變量 –
在控制檯日誌策略{版本不清: '1.0.0', 策略: {[功能:策略] super_:{[功能:OAuth2Strategy] super_:[函數:策略]}}}我們得到這個。 –
甚至當我更新時,它給了我一個字符串相同的錯誤 – Nitin