Tag: karma jasmine

如何使用Jasmine对$ scope.broadcast,$ scope。$进行unit testing

我是AngularJs / NodeJs世界的新手,所以如果这是一个基本的问题,请原谅。 所以简而言之,我有两个控制器,第一个控制器$broadcast一个“Id”,第二个控制器通过$on获取该Id,然后将该Id传递给一个中间service ,这会产生一个$http ajax调用,并返回一个Book对象。 如何使用Jasmine对$ scope.broadcast,$ scope。$进行unit testing firstCtrl .controller('firstCtrl', function($scope, …){ $scope.selectGridRow = function() { if($scope.selectedRows[0].total !=0) $scope.$broadcast('id', $scope.selectedRows[0].id);//Just single plain ID }; }); secondCtrl .controller('secondCtrl', function($scope, bookService) { $scope.$on('id', function(event, id) { bookService.getBookDetail(id).then(function(d) { $scope.book = d.book; }); }); }); 预计Json obj var arr = "book" : [ { "id" : […]

业力不执行testing用例

我是业力新手。 我无法执行testing用例。 我有以下设置。 karma.config.js 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: [ 'angular.js','angular-mocks.js' ,'tests/firstTest.js' ], // list of files […]

Nodejs:peerDependencies错误,同时安装depedencNodejs

在我试图获得我需要的库,npm安装工作良好,直到一年左右,现在当我移动到一个新的服务器,它打破了PeerDependencies错误。 我有点困惑,因为我没有破解代码的原因,有没有人遇到过类似的问题,这可能不是因为旧版本的库被全球预先安装,因为我正在向全新的服务器迁移。 任何帮助在这里将非常感激。 错误 npm ERR! Linux 3.13.0-49-generic npm ERR! argv "node" "/usr/bin/npm" "install" npm ERR! node v0.10.37 npm ERR! npm v2.10.1 npm ERR! code EPEERINVALID npm ERR! peerinvalid The package karma does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer karma-requirejs@0.2.2 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-mocha@0.1.10 wants karma@>=0.12.8 npm ERR! […]

用JStesting文件testing用Karma和Jasmine编译的TypeScript

我有一个具有以下结构的项目: build – out.js spec – foo.spec.js – bar.spec.js src – foo.ts – bar.ts 这两个.ts文件被构build到out.js 。 在我的.spec.js文件中,我希望能够轻松地引用out.js 当在纯JS项目中使用Karma / Jasmine时,我只需要使用RequireJS,并将我的testing文件封装在define(['a'], function(a) { … }); 文件。 然后,在a.js ,内容将如此包装: define([], function() { Foo.prototype. ……. Foo.prototype. ……. return Foo; }); 但是,由于out.js将由TypeScript编译器构build,因此无法封装在define(…)块中,因此无法使用RequireJS正确导入它。 澄清: 用下面的手写JS,我可以把它导入到我的testing文件中: define([], function() { function Bla() { } Bla.prototype.hi = function () { return "hey"; }; […]

问题在Ubuntu下安装业务,茉莉花和phantomjs与NPM

我正在尝试使用yeomen创buildangular度项目。我在yeomen站点中安装了grunt-cli,bower,angular-generator。但是grunt的构build不成功,抛出了以下未满足的依赖性错误。 npm WARN EPEERINVALID grunt-karma@0.12.1 requires a peer of karma@^0.13.0 || >= 0.14.0-rc.0 but none was installed. npm WARN EPEERINVALID karma-jasmine@0.3.6 requires a peer of jasmine-core@* but none was installed. npm WARN EPEERINVALID karma-phantomjs-launcher@0.2.2 requires a peer of karma@>=0.9 but none was installed. npm WARN EPEERINVALID karma-phantomjs-launcher@0.2.2 requires a peer of phantomjs@>=1.9 but none was […]

新手用Karma,Node.js和Jasmine尝试AngularJS

我得到这个错误运行脚本/ test.bat通过控制台 Chrome 48.0.2564 (Windows 7 0.0.0) ERROR Uncaught TypeError: Cannot read property 'module' of undefined 我在Windows 7下,你可以注意到并使用Angular Seed。

Faker.js生成随机path不起作用

我使用faker.js https://www.npmjs.com/package/faker来生成随机数据 。 它工作正常,虽然当我尝试创build一个这样的path faker.system.directoryPath() + '/' + faker.system.filePath() 我一直都没有定义 ,所以它似乎存在,但不返回任何东西。 有没有人使用过这些方法之一? 在此先感谢,任何帮助将非常感激。 再见

Karma-Coverage和Istanbul HTML报告不会输出到预期的目录

我有问题得到伊斯坦布尔输出它的HTML报告到我的噶configuration中指定的目录。 它目前输出正确的目录( reports/coverage )主index.html,但详细的html子页面输出到源文件( www/js/… )相同的目录。 这里和这里描述的是相同的问题,但在尝试build议的解决scheme后,问题依然存在。 这是我的业力configuration文件的内容: basePath: './', frameworks: ['jasmine'], files: [ 'www/lib/angular/angular.js', 'www/js/*.js', 'www/js/services/*.js', 'www/js/controllers/*.js', 'www/lib/angular-mocks/angular-mocks.js', 'tests/**/*test.js', 'tests/test-data/*.json' ], plugins: [ 'karma-jasmine', 'karma-coverage', 'karma-phantomjs-launcher', 'karma-ng-json2js-preprocessor' ], preprocessors: { 'www/js/**/*.js': ['coverage'], 'tests/**/*.json': ['ng-json2js'] }, ngJson2JsPreprocessor: { stripPrefix: 'tests/test-data/', prependPrefix: 'served/' }, reporters: ['progress', 'coverage'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: […]

Karmatesting运行器RequireJS 404错误,不提供内容

获取我的app.js文件的404错误,即使它存在于它所说的URL没有(服务与业力)。 任何想法这是什么以及如何解决? >疯了。 DEBUG [web-server]: serving: /Users/tina/Sites/node_require/client/src/app.js DEBUG [web-server]: serving: /Users/tina/Sites/node_require/client/src/views/add.js WARN [web-server]: 404: /base/client/src/app 我的目录结构: karma.conf.js bower_components/ client/ src/ -app.js -main.js spec/ -app.test.js -test.main.js views/ -add.test.js 我的karma.conf.js: // Karma configuration // Generated on Mon Apr 13 2015 19:36:01 GMT-0400 (EDT) module.exports = function(config) { config.set({ // base path, that will be used to resolve […]

使用ng-scenario作为框架以Karma和Jasminetesting控制器时,范围variables未定义

我刚刚开始使用Karma & Jasmine发现angularunit testing的奥秘,并且我在controllerstesting中遇到了一些问题。 我已经写了testing,看看是否定义variables: expect(scope.someVariable).toBeDefined() 。 一切按预期工作(每个testing都成功了),直到我在karma.conf.js文件中添加了ng-scenario 。 我正在使用node来运行testing。 问题:在karmaconfiguration文件中添加ng-scenario作为框架之后,所有用于检查范围variables是否定义的testing都将失败。 在添加ng-scenario之前,所有的testing都成功了。 你有什么想法为什么会发生这种情况? Karma Conf文件: module.exports = function(config) { config.set({ basePath: '', frameworks: ['ng-scenario','jasmine'], files: [ 'app/plugins/jquery/jquery.js', 'app/plugins/angular/angular.js', 'app/plugins/angular-scenario/angular-scenario.js', 'app/plugins/angular-mocks/angular-mocks.js', 'app/plugins/angular-resource/angular-resource.js', 'app/plugins/angular-cookies/angular-cookies.js', 'app/plugins/angular-sanitize/angular-sanitize.js', 'app/plugins/angular-route/angular-route.js', 'app/plugins/angular-utf8-base64/angular-utf8-base64.js', 'app/scripts/*.js', 'app/scripts/**/*.js', 'test/**/*.js', 'app/views/templates/*.html' ], preprocessors : { 'app/views/templates/*.html': 'html2js' }, exclude: ['app/plugins/angular-scenario/angular-scenario.js'], port: 8080, logLevel: config.LOG_INFO, autoWatch: false, browsers: […]