jasmine

Testing javascript inside IIFE

纵然是瞬间 提交于 2020-01-13 07:24:50
问题 My team leader wants me to wrap my js code inside an IIFE immediatly-invoked function expression. I can't figure out how to spyOn in my jasmine spec file. How would I spyOn the follow: (function(){ function_1(){...} function_2(){...} }); spyOn(window,'function_1') doesn't work. Passing window into the IIFE doesn't work. Trying both (x=function()... and (function x() ... then spyOn(x,'function_1') doesn't work either. I couldn't find anything on-line about this. 回答1: @user29998, if you can

Can Blanket.js work with Jasmine tests if the tests themselves are loaded with RequireJS?

房东的猫 提交于 2020-01-13 06:57:11
问题 We've been using Jasmine and RequireJS successfully together for unit testing, and are now looking to add code coverage, and I've been investigating Blanket.js for that purpose. I know that it nominally supports Jasmine and RequireJS, and I'm able to successfully use the "jasmine-requirejs" runner on GitHub, but this runner is using a slightly different approach than our model -- namely, it loads the test specs using a script tag in runner.html, whereas our approach has been to load the specs

How use require inside a spec - grunt + karma + jasmine in node

余生颓废 提交于 2020-01-13 02:55:08
问题 Vague version question: How can I use require inside a spec with grunt? Context: I'm working on an existent node project that has no tests yet, so I read some and realized to use karma and jasmine. I read some tutos (including these): http://kwilson.me.uk/blog/use-karma-and-grunt-to-run-your-jasmine-tests-in-real-time/ http://ahexamples.blogspot.com.br/2014/03/example-of-jasmine-karma-sonar-grunt.html So I'm trying to run my specs with grunt and getting this error: X encountered a declaration

Karma vs Chutzpah

笑着哭i 提交于 2020-01-12 14:17:35
问题 I have been trying to figure out what is the best way to write/run automated jasmine tests in visual studio. Currently, I am using jasmine with Resharper (using PhantomJS) and the test can be run from visual studio. Now I want to run the tests as part of continuous integration and very are using TFS. Searching online give me few options which made me rather confused. 1) Use Chutzpah as a test runner to execute jasmine tests. 2) Use Karma as a test runner (but it also requires Chutzpah test

Karma vs Chutzpah

南楼画角 提交于 2020-01-12 14:14:08
问题 I have been trying to figure out what is the best way to write/run automated jasmine tests in visual studio. Currently, I am using jasmine with Resharper (using PhantomJS) and the test can be run from visual studio. Now I want to run the tests as part of continuous integration and very are using TFS. Searching online give me few options which made me rather confused. 1) Use Chutzpah as a test runner to execute jasmine tests. 2) Use Karma as a test runner (but it also requires Chutzpah test

Karma vs Chutzpah

十年热恋 提交于 2020-01-12 14:14:03
问题 I have been trying to figure out what is the best way to write/run automated jasmine tests in visual studio. Currently, I am using jasmine with Resharper (using PhantomJS) and the test can be run from visual studio. Now I want to run the tests as part of continuous integration and very are using TFS. Searching online give me few options which made me rather confused. 1) Use Chutzpah as a test runner to execute jasmine tests. 2) Use Karma as a test runner (but it also requires Chutzpah test

How do I debug a Jasmine spec run with Testacular (Karma)?

我们两清 提交于 2020-01-12 13:50:09
问题 I have a small project with Jasmine specs and I am using Testacular as my test runner. I don't understand how I can debug, both the app code or the spec code. When I try to set a breakpoint in Chrome Dev Tools it isn't hit next time the specs run because it loads the files every time with a new query string. The best thing I found so far is to use console.log() but I would rather use Chrome Dev Tools breakpoints. (I am using Visual Studio 2012 for development.) Thanks 回答1: Testacular is not

Babel replaces this with undefined

拈花ヽ惹草 提交于 2020-01-12 11:45:01
问题 This code beforeEach(() => { this.asd= '123'; this.sdf= '234'; this.dfg= '345'; this.fgh= '456'; }); has been transpiled by Babel to: beforeEach(function() { undefined.asd= '123'; undefined.sdf= '234'; undefined.dfg= '345'; undefined.fgh= '456'; }); Why? 回答1: Presumably that code is at the top-level scope of a module, and so it's in strict mode (the default for modules is strict mode), or a file that is being evaluated in strict mode (because it has "use strict" or because of Babel's defaults

Babel replaces this with undefined

非 Y 不嫁゛ 提交于 2020-01-12 11:44:31
问题 This code beforeEach(() => { this.asd= '123'; this.sdf= '234'; this.dfg= '345'; this.fgh= '456'; }); has been transpiled by Babel to: beforeEach(function() { undefined.asd= '123'; undefined.sdf= '234'; undefined.dfg= '345'; undefined.fgh= '456'; }); Why? 回答1: Presumably that code is at the top-level scope of a module, and so it's in strict mode (the default for modules is strict mode), or a file that is being evaluated in strict mode (because it has "use strict" or because of Babel's defaults

Angular Material and Jasmine : “ No provider for InjectionToken MdDialogData! ”

痞子三分冷 提交于 2020-01-11 21:10:00
问题 I have a component which is meant to be used in an Angular Material MdDialog : @Component({ ... }) export class MyComponent { constructor(@Inject(MD_DIALOG_DATA) public data: any, public dialogRef: MdDialogRef<MyComponent>) { ... } } I am trying to Unit Test it with Jasmine : describe('MyComponent', () => { let component: MyComponent; let fixture: ComponentFixture<MyComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ SharedTestingModule, ], declarations: [