jasmine tests in karma: Uncaught ReferenceError: require is not defined

I was facing same issue, when trying to use require(‘module_name’) (CommonJS style modules) inside a test case and running it using Karma. The reason was require function is not available to browser (it is undefined). To provide it to browser we can browserify the test js files before Karma runs test case in browser using … Read more

debug in browser using testacular (now karma)

In karma.conf.js: browsers = [‘Chrome’]; In your failing spec: it(‘spec’, function() { debugger; // This is like setting a breakpoint // … }); Run Karma. Go to the newly opened Chrome Browser, open the console and refresh the page. Now in Chrome’s Developer Tools source tab you should see the execution stopped at the debugger.

How can I get a list of passing tests from karma runner suite?

I know how this can be done! Karma’s terminal output comes from objects called Reporters. Karma ships with some built-in Reporters (they can be found in karma/lib/reporters). Karma is also able to use custom Reporters. You can specify which reporters are used in your project’s karma.config.js file. For example, the ‘dots’ reporter just prints a … Read more

Injecting dependent services when unit testing AngularJS services

Actually in AngularJS Dependency Injection uses the ‘last wins’ rule. So you can define your service in your test just after including your module and dependencies, and then when service A that you’re testing will request service B using DI, AngularJS will give mocked version of service B. This is often is done by defining … Read more

karma test runner detailed test report in console

I was looking for something similar, and found this: https://github.com/usrz/javascript-karma-verbose-reporter. Generates this kind of output: $ karma start –reporters=verbose Suites and tests results: – the app.router.config module : * contains a router property : ok * configures the router title : ok * should have a login route : ok – the organization module : … Read more

ReferenceError: module is not defined – Karma/Jasmine configuration with Angular/Laravel app

Perhaps this will help someone. The solution, for me, was to make sure angular-mocks.js was loaded before my tests. If you’re not sure, you control the order in karma.conf.js under the following section: // list of files / patterns to load in the browser files: [ // include files / patterns here Next, to get … Read more

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