AngularJS Promise Callback Not Trigged in JasmineJS Test

TL;DR Call $rootScope.$digest() from your test code and it’ll pass: it(‘should return false if user is not logged into Facebook’, function () { … var userLoggedIn; inject(function (Facebook, $rootScope) { Facebook.getUserLoginStatus($rootScope).then(function (data) { console.log(“Found data!”); userLoggedIn = data; }); $rootScope.$digest(); // <– This will resolve the promise created above expect(userLoggedIn).toEqual(false); }); }); Plunker here. Note: … Read more

How do I exclude files from karma code coverage report?

You can use several techniques here: karma uses minimatch globs for file paths and use can take advantage of that to exclude some paths. As first solution I’d say try to add only the paths of the file to preprocess with the coverage: // karma.conf.js module.exports = function(config) { config.set({ files: [ ‘src/**/*.js’, ‘test/**/*.js’ ], … Read more

Unable to run Coverage with Karma

I got the same [WARN] because the plugin ‘karma-coverage’ was not defined inside the plugins of the config, try to see if adding it fixes your warning, not sure if it will fix your full problem. plugins: [ ‘karma-jasmine’, ‘karma-coverage’, ‘karma-chrome-launcher’, ‘karma-firefox-launcher’, ], UPDATE: I also had a different problem when running the coverage, caused … Read more

RegeneratorRuntime is not defined

Node js Env – updated December 2015 This question has already been answered, please see accepted answer UNLESS running within NodeJS environment. If like myself, you had the same error message: ‘ReferenceError: regeneratorRuntime is not defined’ but were running Babel within a NodeJS environment, then simply doing the following will likely solve your problem: npm … Read more

How can I run tests with a headless browser?

As a more complete answer based on William Hampshire‘s one, Cuga‘s comment and my personal additions. Short answer: using ChromeHeadless You can just use Headless Chrome: ng test –browsers ChromeHeadless You need to have Chrome 59+. But if you need PhantomJS (and/or chaning the default ng test behaviour with no arguments) read the following. Longer … Read more

Expect not toThrow function with arguments – Jasmine

toThrow matcher requires function to be passed as argument to expect so you can simply wrap your function call in anonymous function: expect(function() { myFunc(arg1, arg2, arg3); }).not.toThrow(); You can also use bind to create new ‘version’ of your function that when called will be passed provided arguments: expect(myFunc.bind(null, arg1, arg2, arg3)).not.toThrow();

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)