jasmine

Karma not running simple typescript test (using SystemJS + Jasmine)

偶尔善良 提交于 2019-12-11 09:05:35
问题 I have been struggling with running a very simple typescript unit test that returns "hello" using Karma, Jasmine, SystemJs. Grabbed the project from Aurelia Typescript ASP.NET Core skeleton here but since then I've got no luck in running the unit tests even those included in the skeleton much less with e2e tests. Since it is from the aurelia skeleton, I am using 'gulp test' to run the unit test. Thanks for your help!! so when running I am getting : 665:DEBUG [config]: autoWatch set to false,

ReferenceError: Can't find variable: $ when running JasmineHeadlessWebkit

↘锁芯ラ 提交于 2019-12-11 08:27:34
问题 I've been trying to find an answer to this at least for the last two hours without any luck. I hope someone here might be able to help. I'm getting this ReferenceError: Can't find variable: $ when running my Jasmine specs using the JasmineHeadlessWebkit. The weird thing is, this only happens when I say $ -> game.init() in my game.coffee file. I can use the $ without any problems further down game.coffee . For example: window.game = init: -> $('.gamelayer').hide() $('#gamestartscreen').show()

Testing an angular (authenticated)service using jasmine

▼魔方 西西 提交于 2019-12-11 08:17:59
问题 I am new in jasmine and trying to write test case.. I am stuck need a little push/help. I am using JASEMINE in my MEAN app. Here is code!! Service angular.module('rugCoPro') .service('AuthenticationService', ['$http', 'ObjectUtils', 'Session', function($http, ObjectUtils, session){ var isError = function(data){ return (ObjectUtils.isObject(data) && data.hasOwnProperty("error")); }; /* * * login * */ this.login = function(username, password, errCallBack, successCallBack){ if(ObjectUtils

Unexpected value 'undefined' imported by the module 'DynamicTestModule' in jasmine-karma

回眸只為那壹抹淺笑 提交于 2019-12-11 08:05:21
问题 I am doing unit testing using jasmine-karma. configuration - "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/jquery": "^3.3.22", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", I am getting the same error for all the test cases. Error: Unexpected

Reg ex to ignore .spec.ts files for AOT angular 5 build

让人想犯罪 __ 提交于 2019-12-11 08:02:04
问题 Angular 5 ngtools isn't ignoring all ".spec.ts" files in my production build. How would I exclude **.spec.ts* but keep any other .ts ? /(?:.ngfactory.js|.ngstyle.js|.ts)$/ From my webpack.prod.config.js... module.exports = merge(baseConfig, { devtool: "source-map", module: { rules: [ { // AOT mode support for production test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, loader: '@ngtools/webpack' } ] }, Click here on link example of image to regex101.com 回答1: If you plan to allow files with

Jasmine Async Testing

删除回忆录丶 提交于 2019-12-11 07:49:26
问题 I'm attempting to test a value that is set asynchronously using Jasmine 2's new done() callback. I've based my test after the example Jasmine gives in their documentation (http://jasmine.github.io/2.0/upgrading.html#section-Asynchronous_Specs): it('can set a flag after a delay', function(done) { var flag = false, setFlag = function() { //set the flag after a delay setTimeout(function() { flag = true; done(); }, 100); }; setFlag(); expect(flag).toBe(true); }); I'm getting the result "Expected

Implement unit testing with jasmine/karma by mocking Http Post - Angular 5

北城以北 提交于 2019-12-11 07:49:01
问题 I am completely new to unit testing and I am implementing unit testing using jasmine/karma for the first time. I am facing few issues in understanding how I should implement testing by mocking for Http Post. I have gone through few solutions such as : solution1 and solution2 But still I have faced few issues in understanding them and have also faced few errors. By following solution2 I have tried to implement as follows: http.service.ts update(id,password,url){ let content = { "username": id,

Backbone collection fetch not populating in Jasmine + Sinon spec

我是研究僧i 提交于 2019-12-11 07:26:53
问题 When I run this spec output I get "Expected 0 to equal 2." 2 is the correct length of model objects in my fixture so Sinon's fakeServer is responding properly with the mocked response. I can't figure out why my Collection has zero objects after fetch then. Any help would be really appreciated! FYI: this is coming from following along the Backbone Sinon + Jasmine tutorial here: http://tinnedfruit.com/2011/03/25/testing-backbone-apps-with-jasmine-sinon-2.html Spec: describe "Todos collection",

ember-couchdb-kit fails all Jasmine specs

江枫思渺然 提交于 2019-12-11 06:55:52
问题 I'm trying to use the ember-couchdb-kit adapter built by roundscope, but it's not working as expected. When I follow the instruction to rake jasmine , it fails all 20 specs, all with the same error, timeout: timed out after 3000 msec waiting for model should be saved (or something closely related to that) Also, my couchdb terminal shows errors like this: [info] [<0.171.0>] 127.0.0.1 - - OPTIONS /doc 404 Here's a pastebin for every output given by couchdb after the spec is run. I've set this

How to make catched promises fail in jest

佐手、 提交于 2019-12-11 06:49:39
问题 Consider this function: aPromise = require('axios'); function middleware(callback) { axios.get('/api/get') .then(callback) .catch(callback); } Consider this test: const callback = (err) => { expect(isError(err)).toBe(true); done(); }; middleware(callback); The isError is a lodash function. Consider aPromise as something I want to test. If the promise always resolves, this test should not pass. But it will! And that's because the promise's catch actually catches the expect exception. My