Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
@electrofLy It was because of having window.location.replace code execution in a karma test :P
Joe Pea
Hi, I have a day pipe which translates the dates to daynames in user specific languages, but i don't know how to mock the service call
      case 0:
        //calling the service here should return 'Sunday' in the appropiate language (this works)
       //I want to build a mock in my test for this: this.lang["core.shared.pipes.weekdays.sunday"]
        return this.lang["core.shared.pipes.weekdays.sunday"];


  get lang() : string {
    return this.language.lang;
  constructor(private language: AppLanguageService) {}
To test this i thought i had to do following, but this doesn't work:
let mockLanguageService;

    beforeEach(() => {
        mockLanguageService = jasmine.createSpyObj(['lang'])

            imports: [],
            declarations: [],
            providers: [
              {provide: AppLanguageService, useValue: mockLanguageService},

        // this is wrong, how do I do this correctly?:
            ['core.shared.pipes.weekdays.monday']:    "monday",
            ['core.shared.pipes.weekdays.tuesday']:   "tuesday",
            // ...
Nevermind I found it
mockLanguageService.lang = ({
            ['core.shared.pipes.weekdays.monday']:    "monday",
            ['core.shared.pipes.weekdays.tuesday']:   "tuesday",
Alexander Reitzel
I'm trying to set up a sample project that lets me write modular JS code (either ES6 import/export or requirejs) with a test framework (possibly Jasmine), for websites, and using ChromeHeadless so I can run the same tests on CI.
It's a bit discouraging how much effort that seems to be. Maybe it's even too much effort.
I'd appreciate some advice, pointers, or confirmation that what I'm doing is not very feasible without extensive hacks, or even working examples that I haven't yet tried myself.
It would be really nice to be able to write unit-tested and code coverage measured JS code for websites, without much more overhead.
Cody Mikol
Why is it a lot of effort?
Alexander Reitzel
I find there are many tools which have been used over the years, and a lot of examples and documentation, and some libraries and frameworks fit together, but some things are just possible with this combination and some with that. It's a large amount of moving parts to consider.
Cody Mikol
If you find it overwhelming, Iā€™d suggest cloning a nodejs starter repository
Rather than try to understand the whole thing see how each piece works independent of the other
Alexander Reitzel
I had jasmine running in a nodejs environment before. Sort of.
I got confused when trying to use the same template project for both browser based and nodejs based projects
https://github.com/FunTimeCoding/java-script-skeleton/blob/develop/Gruntfile.js this one has most of the things I tried working with the browser part
namely: there is modular code that runs through browserify and gets included, and the code in my main class is being executed
but what doesn't work this way is the jasmine and requirejs are setup
Hi All
this is the first time I am joining this room
Cody Mikol
Welcome šŸ‘½

I have question in stack overflow for karma this is the first time iam using jasmine and karma

can some one please help me I am struggling lot


Please help me
Aaron Gray
Anyone know how to use karma-fixture with TypeScript and TypeScript Unit Tests ? I think I have all the development files in place but 'fixture' does not seem to be visible like it is in plain JavaScript. The TypeScript compiler is compiling it fine and not complaining. I have tried using @types/karma-fixture but that does not seem to help.
Aaron Gray
OKay seem to have solved that !
Peter Sulatycke
Does karma support CommonJs out of the box or must you bundle the code first (eg webpack)? I see there is an old karma-commonjs npm project. Are people still using that? I wish the karma document mentioned something about CommonJs. Thanks
Hello everyone! if i have a test, so inside a "describe" element, i get some data trough require, how do i access given data inside each of my "it" statements without calling the endpoint multiple times?
Hi, I would like to use latest karama npm package without vulnerability. When is latest package published?
Elon Mallin
Hi, does anyone know of a way to use karma interactively? I know the tests are meant to run without user interaction but I have an external device that I need to interact with to get real responses. I don't want to mock these responses.
Dave Bush
Even a pointer to someone's working implementation would work.

Hi all. I am getting crazy with an issue in my jasmine tests,
specifically when testing the drag & drop event.
It turns out that when I run my test specifying the parameter "--browsers=ChromeHeadless"
the "drop" event is not fired, and as a consequence its inner function either.
However when removing the parameter "--browsers=ChromeHeadless", everything works as a charm.

Do you have guys any idea what is happening? thanks :)

Ben Tilford
I've got an issue with karma exiting with an error even though the tests ran. Disconnected (0 times), because no message in 5000 ms This happens for Chrome/Firefox headless or not as well as puppeteer. Any ideas what sort of things cause this?
I played around with captureTimeout: 5000, browserNoActivityTimeout: 5000, browserDisconnectTimeout: 5000, browserDisconnectTolerance: 1,
but none of those did anything other than make it faster/slower to error out
Jared McCannon
Does anyone have a good resource for adding karma and jasmine to an existing angular application?
Everything I've seen so far is using the CLI to spin up a new app
Dave Bush
@jrmccannon if it were me, I'd spin up a new app and copy and paste the differences into the existing app.
I currently depend on karma@2.0.0 and am advised to stop using HttpModule and switch to HttpClientModule. I can't find any release notes for Karma. How do I select a release that does not require HttpModule?
I have almost 5000 test cases and am running test cases in vsts but everytime i run test cases i get diffrent fail count or sometimes only partially it get run... guyes plz help me out
karma is existing after running few test cases can any one knows this issue? Disconnected (0 times)reconnect failed before timeout of 210000ms (ping timeout)
Disconnectedreconnect failed before timeout of 210000ms (ping timeout)
Hi All, We are seeing a strange error when we run karma with Requirejs in Jenkins, this is an intermittent issue, I followed this guide, https://karma-runner.github.io/0.8/plus/requirejs.html but sometimes we see below error out of blue. The same error we see in different modules every time it fails. We were thinking that the requirejs is not completely loaded before our tests run. But the above doc says
// ask Require.js to load these files (all our tests)
    deps: tests,

    // start test run, once Require.js is done
    callback: window.__karma__.start
14:01:39  START:
14:01:39  16 06 2020 21:01:14.564:WARN [filelist]: All files matched by "/home/jenkins/atgpf/workspace/hello/packages/ui-components/node_modules/karma-typescript/dist/client/commonjs.js" were excluded or matched by prior matchers.
14:01:39  16 06 2020 21:01:15.830:INFO [compiler.karma-typescript]: Compiling project using Typescript 3.9.5
14:01:39  16 06 2020 21:01:29.343:INFO [compiler.karma-typescript]: Compiled 136 files in 12623 ms.
14:01:39  16 06 2020 21:01:33.193:INFO [karma-server]: Karma v4.4.1 server started at
14:01:39  16 06 2020 21:01:33.193:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
14:01:39  16 06 2020 21:01:33.199:INFO [launcher]: Starting browser ChromeHeadless
14:01:39  16 06 2020 21:01:34.282:INFO [HeadlessChrome 80.0.3987 (Linux 0.0.0)]: Connected on socket ZayUg2CQyOR_jdX7AAAA with id 65385820
14:01:39  HeadlessChrome 80.0.3987 (Linux 0.0.0) ERROR
14:01:39    Uncaught Error: Script error for "jqueryui-amd/position", needed by: ojs/ojpopupcore
14:01:39    https://requirejs.org/docs/errors.html#scripterror
14:01:39    at node_modules/requirejs/require.js:143:9
14:01:39    Error: Script error for "jqueryui-amd/position", needed by: ojs/ojpopupcore
14:01:39    https://requirejs.org/docs/errors.html#scripterror
14:01:39        at makeError (node_modules/requirejs/require.js:168:17)
14:01:39        at HTMLScriptElement.onScriptError (node_modules/requirejs/require.js:1738:36)
14:01:39  Finished in 1.625 secs / 0 secs @ 21:01:35 GMT+0000 (Coordinated Universal Time)
14:01:39  SUMMARY:
14:01:39  āœ” 0 tests completed
Lodewijk Wensveen
Is there any way for karma to tell you which files warnings originate from?
Hi, I am trying to integrate saucelab into my angular application which is using travsci, I added one karma.sauce-config.js file application level with saucename,acesskey and browser detaisl, but am not sure how to run this to seee the test results in local as well as in saucelab. npm test is always excuting karma.config.js file
Lodewijk Wensveen
For anyone wondering, if you run the tests inside an IntelliJ ide like webstorm it shows you which files the warnings originate from
Jochem Brouwer
Heya! I want to run a preprocessor in karma with handleBinaryFiles set to true but I don't understand how to configure this.

Tried this:

browserifyPreprocessor: { handleBinaryFiles: true, options: {handleBinaryFiles: true} }, (in karma.conf.js) but browserify still refuses to handle my binary files

Hello everyone :)
I have a problem with Karma in enterprise angular project (500k+ LOC). Karma starts the Chrome browser too early without waiting for the Angular compilation to complete, since the project isn't a small one it takes some time to compile. Chrome timeouts before the compilation is finished. :(
We had to workaround the issue with captureTimeout: 600000, but this solution is not too optimal.
Best case scenario Karma would wait till compilation completes and just then launch the browser. I wonder if such approach would be possible to implement? I had scanned through the Karma's source code, but didn't manage to find proper place to start mingling with.
I kindly ask for your guidence :D