Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
sKudum
@sKudum
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
@lwensveen
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
@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

Kacper
@Jingiel
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
Parker Mauney
@ParkerM
Howdy. Any idea when a release will be cut so this fix becomes available? karma-runner/karma#3565
Abhijeet Jain
@abhijeetj100

Hey guys,
I am facing an issue when trying to run unit tests locally.
I get the error saying:
"ChromeHeadless have not captured in 60000ms, killing."
Error screenshot

It runs fine on Jenkins, and this happens for every project on my system.

Running these tests for projects written using Vue+Typescript.

Any suggestions as to what can be done here?

PS: Apologies if I posted at the wrong place, new here. In that case pls let me whom should I reach out to.

Thanks

Lucio Messina
@melfnt
Hi, I have an issue: I have an Angular11 application in which I set up a web-worker that use a typescript file as target. This works flawlessly if I run the application in the browser but when I run the tests Karma cannot find the script (web browser returns 404). I saw that similar issues were solved if the script is a javascript file, but what about typescript? Here you can find more details about my issue: https://stackoverflow.com/q/65585067/9277537
iftee-hussain
@iftee-hussain
@abhijeetj100 I am facing the same issue but the opposite. It fails in jenkins but works ok locally
Cody Mikol
@codymikol
@abhijeetj100 @iftee-hussain what version of karma-webpack are you using?
iftee-hussain
@iftee-hussain
@codymikol
    "karma": "^5.2.3",
    "karma-chrome-launcher": "^3.1.0",
    "karma-coverage": "^2.0.3",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-diff-reporter": "^2.0.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-sourcemap-loader": "^0.3.8",
    "karma-spec-reporter": "0.0.32",
    "karma-webpack": "^4.0.2",
Cody Mikol
@codymikol
@iftee-hussain can you update karma-webpack to 5.0.0 and let me know what the results are?
2 replies
Tobias Andersen
@turbolego
ERROR: 'NG0303: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'.'
Chrome  (Windows 10): Executed 27 of 210 (skipped 1) SUCCESS (0 secs / 0.609 secs)
ERROR: 'NG0303: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'.'
Chrome  (Windows 10): Executed 69 of 210 (skipped 1) SUCCESS (0 secs / 1.995 secs)
ERROR: 'NG0304: 'mat-list' is not a known element:
1. If 'mat-list' is an Angular component, then verify that it is part of this module.
2. If 'mat-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.'
Chrome  (Windows 10): Executed 90 of 210 (skipped 1) SUCCESS (0 secs / 3.308 secs)
ERROR: 'NG0304: 'mat-list' is not a known element:
1. If 'mat-list' is an Angular component, then verify that it is part of this module.
ERROR: 'NG0304: 'mat-list-item' is not a known element:
1. If 'mat-list-item' is an Angular component, then verify that it is part of this module.
2. If 'mat-list-item' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.'
Chrome (Windows 10): Executed 90 of 210 (skipped 1) SUCCESS (0 secs / 3.308 secs)
ERROR: 'NG0304: 'mat-list-item' is not a known element:
1. If 'mat-list-item' is an Angular component, then verify that it is part of this module.

I have a bunch of errors in my console, and no way to figure out which file has which error.

Is there a way to add the file-name of the offending file where the error occurs?

I have upgraded to karma-jasmine 4.0.1.

Thanks! 😄

1 reply
Tobias Andersen
@turbolego

Errors i get:

  ErrorComponent
ERROR: 'NG0303: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'.'
Chrome 88.0.4324.150 (Windows 10): Executed 27 of 210 SUCCESS (0 secs / 0.92 secs)
ERROR: 'NG0303: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'.'
ERROR: 'NG0303: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'.'
Chrome 88.0.4324.150 (Windows 10): Executed 27 of 210 SUCCESS (0 secs / 0.92 secs)
ERROR: 'NG0303: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'.'
Chrome 88.0.4324.150 (Windows 10): Executed 28 of 210 SUCCESS (0 secs / 0.95 secs)

My spec file:

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ErrorComponent } from './error.component';

describe('ErrorComponent', () => {
  let component: ErrorComponent;
  let fixture: ComponentFixture<ErrorComponent>;

  beforeEach(waitForAsync(() => {
    TestBed.configureTestingModule({
      declarations: [ErrorComponent]
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(ErrorComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

ts-file:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-error',
  templateUrl: './error.component.html',
  styleUrls: ['./error.component.css']
})
export class ErrorComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

html-file:

<p>
  error works!
</p>

Why do i get an error about "mat-dialog-close" and "button" here?
Neither the ts-file, the html-file or the spec-file mentions "mat-dialog-close" or "button" ? 🤔

Mykola Khodan
@mkhodan
Hi guys, I found an issue un karma-runner/karma-coverage package and create a PR with fix, do you know who can I ask to review it?
Daniel Becroft
@danielbecroft
Hi, we're seeing a strange issue where tests are running twice inside of our CI build process.
The tests are being run with ng test --watch=false --code-coverage. Running the same command locally (on the same configuration) does not trigger a duplicate run.
ejnelson15
@ejnelson15
I'm running into an error while running a testbucket, using karma 6.3.2 on angular 11.2.12 (if the matters) "An error was thrown in afterAll" followed by "Uncaught SyntaxError: Cannot use import statement outside a module". I've a number of suggestions that I've found online with no luck. Any ideas on what the problem might be or tips on debugging problem in 'afterAll'?
I should also mention that the error that shows up in the browser is "Error during loading: Uncaught SyntaxError: Cannot use import statement outside a module in http://localhost:9876/base/test.ts?02d5c53632af01b47b1d6dc8ac5000ca33557447 line 3"
line 3 of that file is: 'import 'zone.js/dist/zone-testing';'
ejnelson15
@ejnelson15
hmm, just noticed that karma works on node.js 6.x 8.x and 10.x . I've got v14.15.5. :( .
ejnelson15
@ejnelson15
Still failing the same way with node.js 10.x
Doma
@SevenOutman
I wonder whether there's anyone out there maintaining karma-browserstack-launcher
Doma
@SevenOutman
Is the project still alive?
Doma
@SevenOutman
I guess either answer is NO
Timo Tijhof
@timotijhof:matrix.org
[m]
@SevenOutman: It is, and karma-browserstack-launcher is also used a fair bit. We use it at Wikimedia in a couple of projects. I think jQuery and QUnit also use it in their repos.
José Gomes
@jgomesmv
Hi there!
I left an angular component not declared in one of my unit tests
Now I receive this error on the spec report but I have no idea in which spec file it's happening:
ERROR LOG: 'NG0303: Can't bind to 'icon' since it isn't a known property of 'nb-icon'.'
Any idea on how to address this?
Thanks!
Doma
@SevenOutman

@SevenOutman: It is, and karma-browserstack-launcher is also used a fair bit. We use it at Wikimedia in a couple of projects. I think jQuery and QUnit also use it in their repos.

I'm having a hard time setting up karma-browserstack-launcher to run in GitHub Actions as recorded in rsuite/rsuite#1707. Can't have it running and can't find a running example either. Opened several issues but got no response.

Doma
@SevenOutman
Neither jQuery nor QUnit is using karma-browserstack-launcher. jQuery has karma-browserstack-launcher in their package.json as devDepencencies but is not using it. QUnit is using browserstack-runner.
Timo Tijhof
@Krinkle

@SevenOutman: I'm having a hard time setting up karma-browserstack-launcher to run in GitHub Actions as recorded in rsuite/rsuite#1707. Can't have it running and can't find a running example either. Opened several issues but got no response.

Aye, I'd recommend against parallel jobs in that way. That shouldn't be needed since karma manages concurrency for you already. If you must separate them, it'll require a stronger separation in the config. I also don't know if that might run into a quota limit. Afaik it allows many parallel browsers, but not sure if it can also allow the same number of parallel tunnels.

QUnit is using browserstack-runner.

Oops, that's my bad, yes. We don't use karma in the actual qunit repo right now, but that's only because karma-qunit imports the qunit module on its own, which is great, unless you are qunit itself, in which case that wouldn't test what we want it to test. I'll likely change that to use karma-tap at some point, and then naturally use karma-browserstack-launcher.

Naresh Yella
@nareshram:matrix.org
[m]
Disconnected (0 times)reconnect failed before timeout of 2000ms (transport close)
HeadlessChrome 75.0.3770 (Linux 0.0.0) ERROR
Disconnectedreconnect failed before timeout of 2000ms (transport close)
HeadlessChrome 75.0.3770 (Linux 0.0.0): Executed 1424 of 1515 (skipped 4) DISCONNECTED (32 mins 13.678 secs / 32 mins 5.586 secs)
HeadlessChrome 75.0.3770 (Linux 0.0.0) ERROR
Disconnectedreconnect failed before timeout of 2000ms (transport close)
HeadlessChrome 75.0.3770 (Linux 0.0.0): Executed 1424 of 1515 (skipped 4) DISCONNECTED (32 mins 13.678 secs / 32 mins 5.586 secs)
Can someone please help me to figure out what is the issue here
While running the tests on VM all looks good, but when we start the pipeline (Jenkins) we are seeing this error
dotnetCarpenter
@dotnetCarpenter
What does it say if you crank up the log level? logLevel: config.LOG_DEBUG,
Also I vaguely remember having issues with Chrome and the DISPLAY environment variable. What does echo $DISPLAY say?
kmgzc
@kmgzc
Hello, I am puzzled by update karma to 6.3.4(or event 6.0.0), my unit test with angularJS and jasmine cannot work well. Each time I do the 'karma start' command, there always comes up with some timeout error to me, event I add done() to afterEach. Is there something wrong with my test case?
kmgzc
@kmgzc
My jasmine.DEFAULT_TIMEOUT_INTERVAL is 5seconds and don't want to change it. I kindly ask for your guidence.
Cody Mikol
@codymikol
@kmgzc how long do your tests take to run?
kmgzc
@kmgzc

@kmgzc how long do your tests take to run?

The whole take about 4-5minutes, but the failure is more than 5 seconds.

Cody Mikol
@codymikol
You’ll either need to up your timeout interval, or make that test run faster than 5 seconds
Those are the only real options
Cody Mikol
@codymikol
It looks like you can also pass a timeout per “it” with jasmine/jasmine@68ba5b6
Doma
@SevenOutman

Aye, I'd recommend against parallel jobs in that way. That shouldn't be needed since karma manages concurrency for you already. If you must separate them, it'll require a stronger separation in the config. I also don't know if that might run into a quota limit. Afaik it allows many parallel browsers, but not sure if it can also allow the same number of parallel tunnels.

@Krinkle Thanks! I managed to run multi-browser tests in a single job. But there's one thing I can't achieve with single job is that it can't generate coverage separately for each browser (in case source code was executed differently in different browsers).

Timo Tijhof
@Krinkle
I believe karma-coverage takes care of that. Last I checked it stores the result of each browser in a separate sub directory like coverage/Firefox and coverage/Chromium. It might be that you have set the directory explicitly, in which case they could get overridden.
Doma
@SevenOutman

I believe karma-coverage takes care of that. Last I checked it stores the result of each browser in a separate sub directory like coverage/Firefox and coverage/Chromium. It might be that you have set the directory explicitly, in which case they could get overridden.

I see, thanks!

Kahn Le
@kahn_le_twitter
The Karma js was using the "ua-parser-js" package, The package has a security issue, Do you have a plan to change using the package to another for safety?