karma-runner

Why is the Karma configuration file exclude option is not working?

蹲街弑〆低调 提交于 2020-07-18 14:34:27
问题 I have two spec files in my sample Angular app. The spec files names are src/app/app.component.spec.ts & src/app/app.component-two.spec.ts . I want to run only the tests in file src/app/app.component.spec.ts . So, I added the other file as exclude in the karma.conf.js file (pasted below), still the tests mentioned in the exclude option are being executed. Any help is greatly appreciated. // Karma configuration file, see link for more information // https://karma-runner.github.io/1.0/config

Spec has no expectation console error although expect is present

人盡茶涼 提交于 2020-07-09 05:25:17
问题 I have the spec that has to expect still it says there are no expectations... it('should click on yes button of technician and check save&continue functionality', () => { const saveAndContinue = fixture.debugElement.query(By.css(saveContinueBtn)).nativeElement; saveAndContinue.click(); fixture.detectChanges(); fixture.whenStable().then(() => { const spy = spyOn(component, 'isSaveAndContinueClicked').and.callThrough(); expect(component).toBeDefined(); expect(spy); component

Spec has no expectation console error although expect is present

拈花ヽ惹草 提交于 2020-07-09 05:25:10
问题 I have the spec that has to expect still it says there are no expectations... it('should click on yes button of technician and check save&continue functionality', () => { const saveAndContinue = fixture.debugElement.query(By.css(saveContinueBtn)).nativeElement; saveAndContinue.click(); fixture.detectChanges(); fixture.whenStable().then(() => { const spy = spyOn(component, 'isSaveAndContinueClicked').and.callThrough(); expect(component).toBeDefined(); expect(spy); component

Angular 7 : ng test hangs , keeps running tests repeatedly

我只是一个虾纸丫 提交于 2020-07-06 08:59:14
问题 i ve recently migrated my Angular 6 app to Angular 7 my package.json looks like this : { "name": "myApp", "version": "3.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve --public-host http://localhost:4200/", "build": "ng build --prod", "serve": "ng serve --optimization=true --source-map=true --eval-source-map=true --live-reload=true --aot=false --vendor-chunk=true", "build-prod": "node --max_old_space_size=5000 ./node_modules/.bin/ng build --configuration=production",

Angular 7 : ng test hangs , keeps running tests repeatedly

孤街浪徒 提交于 2020-07-06 08:57:32
问题 i ve recently migrated my Angular 6 app to Angular 7 my package.json looks like this : { "name": "myApp", "version": "3.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve --public-host http://localhost:4200/", "build": "ng build --prod", "serve": "ng serve --optimization=true --source-map=true --eval-source-map=true --live-reload=true --aot=false --vendor-chunk=true", "build-prod": "node --max_old_space_size=5000 ./node_modules/.bin/ng build --configuration=production",

Angular Karma not capturing browser

落爺英雄遲暮 提交于 2020-06-28 05:14:11
问题 I've an existing project on Angular 6 where tests not running. How it happens: in PhpStorm I press in context menu on file run file.specs.ts . It starts test, opens the browser and nothing is happening then. Here is the log Waiting for a captured browser... To capture a browser open http://localhost:9876/ 14 10 2018 13:04:17.500:WARN [launcher]: Chrome have not captured in 60000 ms, killing. 14 10 2018 13:04:17.799:INFO [launcher]: Trying to start Chrome again (1/2). 14 10 2018 13:05:17.808

How to exclude mock files from Code Coverage Istanbul Reporter

烂漫一生 提交于 2020-06-13 19:02:12
问题 I have a question regarding Istanbul Reporter used for reporting my unit testing coverage in my angular 6 application. My problem is: when the coverage is rendered, I see the mocks in the tested files list and obviously the mocks aren't tested, which gives me wrong coverage stats. This is my karma.conf file setup by a colleague and I'd like to know if you have any idea on how to exclude those mock files. module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '

How to disable webpack minification for classes names

我怕爱的太早我们不能终老 提交于 2020-05-29 08:27:28
问题 I use jasmine , karma and webpack to test my module. The webpack preprocesses my tests files before initiating tests. In my tests I have the class Name{...} to be tested. I create new Name instance and then, in my tests I expect(myInstance.constructor.name).toBe("Name") class Name{} const myInstance = new Name(); describe("The object",function(){ it("should be the instance of Name class",function(){ expect(myInstance.constructor.name).toBe("Name"); // Expected 't' to be 'Name'. }) }); But it

Publish Karma unit tests in Jenkins

六月ゝ 毕业季﹏ 提交于 2020-05-26 05:30:41
问题 Jenkins already builds my Maven Java project. I want the results of karma unit tests to show up in Jenkins, but unfortunately I cannot introduce any configuration changes in Jenkins. How karma should be configured to acomplish that? 回答1: in order for Jenkins to be able to parse karma test results they must be published in the Junit XML format, the plugin that does that is karma-junit-reporter junit test results ( outputFile in the karma configuration file) must be stored in target/surefire

get two divs by class name in karma test (Angular 4.0)

梦想与她 提交于 2020-05-13 14:27:30
问题 I have something like this in view: <div> <div class="header-title">Example title 1</div> </div> <div> <div class="header-title">Example title 2</div> </div> In my karma test I would like to investigate all divs by class name and check if inner text is correct so I have following code in test: [...] debugTest = fixture.debugElement.query(By.css('.header-title')); elementTest = debugTest.nativeElement; [...] it('should component div has a correct value', () => { fixture.detectChanges(); const