0
我已经看了几天,现在我明显失去了一些东西。我已经通过Google进行了搜索,并尝试从其他许多人中继续使用egghead.io中的示例。我已经成功将业力安装到WebStorm 8.0.3中,并且我可以运行测试测试,例如expect(true).toBe(true)
或expect(false).toBe(true)
,并获得预期的结果。但是,当我尝试测试helloWorld()
函数时,我收到一个helloWorld未定义的引用错误。Karma如何知道在WebStorm中寻找功能的位置?
如何告诉我的测试脚本我的脚本被测试的位置是?
我的文件结构:
-scripts
--helloWorld.js
-test
--spec.js
karma.conf.js
karma.conf.js(出由WebStorm生成的框的):
// Karma configuration
// Generated on Tue Jun 10 2014 16:47:49 GMT+0100 (GMT Daylight Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files/patterns to load in the browser
files: [
'test/spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable/disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable/disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
spec.js:
describe('heelo world', function(){
it('should say hello', function(){
expect(helloWorld()).toBe('hello world')
})
})
为HelloWorld。 js:
var helloWorld = function(){
return 'hello world'
}
感谢
该诀窍。我以为我曾尝试过,但我不能。谢谢 :) – lappy