Cannot install phantomJS in Karma
npm install karma-jasmine –save-dev npm install karma-phantomjs-launcher –save-dev Then add the following line to karma.config.js plugins : [‘karma-jasmine’, ‘karma-phantomjs-launcher’]
npm install karma-jasmine –save-dev npm install karma-phantomjs-launcher –save-dev Then add the following line to karma.config.js plugins : [‘karma-jasmine’, ‘karma-phantomjs-launcher’]
Here is my solution for the ones using Rxjs 6 let mockService = { getData: () => { return of({data:’any data’}); } } spyOn(mockService , ‘getData’).and.callFake(() => { return throwError(new Error(‘Fake error’)); });
Was facing the same issue and I solved it by editing the karma.conf.js and karma-e2e.conf.js files which is under config directory. Change: browsers = [‘Chrome’]; TO browsers = [‘Your_System_Path_where_chrome_installed/chrome.exe’]; in my case it was > C:/Program Files (x86)/Google/Chrome/Application/chrome.exe and then add C:\Program Files (x86)\Google\Chrome\Application\chrome.exe path to environment variables or in cmd SET CHROME_BIN = “C:\Program … Read more
I seem to have fixed my problem, for anyone with a similar problem: Within my karma.conf.js I added the following: plugins: [ ‘karma-chrome-launcher’, ‘karma-jasmine’ ], At first I added ‘karma-jasmine’ but was then met with “Can not load “Chrome”, it is not registered!” This was solved by adding ‘karma-chrome-launcher’ as a plug-in Not sure if … Read more
As I mentioned in a comment to your question – PhantomJS saves a lot of hassle. That aside, I believe you can handle everything from within your Gruntfile and just continue to run grunt test to start the whole thing. grunt-karma allows full customization of your karma options with some handy add-ons. From the docs: … Read more
Use an ENV variable to pass the argument to files in karma.conf.js: files: [ include1, include2, …, includeN, process.env.JS_TESTS + “/*.js” ] Then run karma like so: JS_TESTS=test/category2 karma start karma.conf.js
You can try putting $rootScope.$apply() in an afterEach() callback function. Promises resolve on $apply() in Angular. afterEach(function(){ rootScope.$apply(); });
Ah, obvious now…I can access the vm variable through making a reference to the controller that’s created in the test: it(“should assign Dashboard as title”, function () { var vm = controller(“dashboard”, { $scope: scope }); expect(vm.title).toBe(“Dashboard”); });
I found that if you create a C:\tmp\karma folder under Windows, this error goes away, and Chrome finds and uses this folder for temp files. You can also change the temporary folder that Chrome uses for its data by setting the TEMP environment variable like so: export TEMP=’/path/to/your/folder’ The important thing is that C:\path\to\your\folder must … Read more
You should use karma start command to execute karma test suite from command line.