karma-runner

Karma tests fail with Browser DISCONNECTED error, exit code: 1

心已入冬 提交于 2021-02-19 05:27:34
问题 We have a total of 2016 unit test cases written with Jasmine and are using Karma to run them. The tests run for a period of 1 min 30 sec to 2 min and then suddenly Karma disconnects from the browser.Here is a screenshot of the console logs. The problem is that I am not able to diagnose why that is happening and which test case is causing it to get disconnected. I have tried different reporters of Karma to be able to identify the test case which forces it to disconnect from the browser but

Karma tests fail with Browser DISCONNECTED error, exit code: 1

萝らか妹 提交于 2021-02-19 05:26:19
问题 We have a total of 2016 unit test cases written with Jasmine and are using Karma to run them. The tests run for a period of 1 min 30 sec to 2 min and then suddenly Karma disconnects from the browser.Here is a screenshot of the console logs. The problem is that I am not able to diagnose why that is happening and which test case is causing it to get disconnected. I have tried different reporters of Karma to be able to identify the test case which forces it to disconnect from the browser but

Read File inside a Jasmine Karma test

一笑奈何 提交于 2021-02-19 05:18:28
问题 I have a service which acts on a file uploaded. I have a function in the service which basically converts the uploaded(.xlxs) file into workbook. I would want to write test case for this particular function. (Not uploaded to server but just to browser) Can anyone suggest on how to access a test file(say test_something.xlxs) from inside the unit test scenario. I would want to read the file as a binary string and pass on the object to the service methods. Unit testing framework i use is Karma +

Read File inside a Jasmine Karma test

荒凉一梦 提交于 2021-02-19 05:13:11
问题 I have a service which acts on a file uploaded. I have a function in the service which basically converts the uploaded(.xlxs) file into workbook. I would want to write test case for this particular function. (Not uploaded to server but just to browser) Can anyone suggest on how to access a test file(say test_something.xlxs) from inside the unit test scenario. I would want to read the file as a binary string and pass on the object to the service methods. Unit testing framework i use is Karma +

Why can't I determine the path for require.context in a karma shim by passing a variable?

一个人想着一个人 提交于 2021-02-10 17:27:34
问题 I want to set the path for require.context(path, ...) in a shim file called by karma (set in the files parameter in the config) dynamically, but somehow, as soon as I use a variable for path, I get the error 'Cannot find module "."' in the CLI. This is very odd, because if I hardcode the very same path into the call, it runs without a problem. Aka, if I do var testPath = '../src'; console.log("PATH 2 " + testPath); // ../src var appContext = require.context(testPath, true, /\.spec\.ts/); I'll

404 on Karma when trying to use web worker

こ雲淡風輕ζ 提交于 2021-02-08 04:37:27
问题 I'm getting the error WARN [web-server]: 404: /app/workers/total.js when trying to run a unit test on a web worker. Karma.conf.js includes the following: ... files: [ ... 'app/workers/*.js', 'unit-tests/mocks/**/*.js', 'unit-tests/src/**/*.js' ], .... the test goes as follows: describe('totals', function () { var worker; beforeEach(function() { worker = new Worker('/app/workers/total.js'); }); it('should do something', function () { ... }); }); I have tried many urls, but none seem to work

Angular 7 - catching HttpErrorResponse in unit tests

感情迁移 提交于 2021-02-07 08:17:41
问题 i'm currently learning Angular 7 (haven't used any previous version) and encountered something i couldn't fix when writing unit tests for a service. I have a service that gets JSON from REST and parses it into a Class. Referring to the Angular Docs, i wrote a test using HttpClientSpy to simulate a 404 Error. What happens: The Test Fails with the Error Message: "expected data.forEach is not a function to contain '404'" So the Service gets the HttpErrorResponse as Input but tries to parse it

npm test --codecoverage doesn't generate report

百般思念 提交于 2021-02-05 07:10:45
问题 Have no ideas why when I hit npm test --codecoverage All test is being executed, however I see an empty '/coverage' folder with no single report. I use angular-cli What I'm doing wrong? 回答1: If you have the CLI installed globally, The command is ng test --code-coverage If you want to use the npm scripts , you will need to do npm test -- --code-coverage 回答2: I believe the command is npm test --coverage There is no check on arguments passed, so you can put in anything you like without it

Test lit-element webcomponent with Karma

情到浓时终转凉″ 提交于 2021-01-29 11:28:51
问题 I am trying to create a blank project, like a template, using lit-html. I wanted to also add some testing capabilities, so i have been trying to get it to work with Karma. I can run a normal test, like an addition, without any errors, so i think Karma itself is running ok. but i can't run any test involving the webcomponent. I can't import the webcomponent! i am exporting the webcomponent with: export default class MyComponent ... and then on the test file i am importing it with: import

Karma: “Disconnectedreconnect failed before timeout of” with ChromeHeadless

浪尽此生 提交于 2021-01-27 22:11:42
问题 In my AngularJS, npm times out when running tests, with message "Disconnectedreconnect failed before timeout of Xs" . My karma.conf.js file is configured as such: ... browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3, browserNoActivityTimeout: 100000, ... Increasing these values didn't help - the same error would appear after the newly specified amount of time. 回答1: I solved it by adding this to my karma.conf.js file, below the browserNoActivityTimeout property. flags: [ '-