jasmine

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 +

Testing angular service with $httpBackend with async/await using jasmin

别等时光非礼了梦想. 提交于 2021-02-18 13:47:45
问题 I have previously successfully tested an angular controller that uses ES7 async/await syntax with jasmine - async updateGridAsync() { const paging = angular.copy(this.gridData.getServerCallObj()); } try { const model = await this.service.getAsync(paging); this._$rootScope.$apply(); } catch (e){this._notification.error(this._$rootScope.lang.notifications.unexpectedError); } } it('updateGridAsync() should update the gridData when succeed', async (done) => { expect(ctrl.gridData.totalItems)

Jasmine avoid beforeEach for certain tests

徘徊边缘 提交于 2021-02-18 10:45:29
问题 Is there a way to NOT execute beforeEach function only for certain tests ('it' blocks). Lets say I have 10 it blocks, I do not want beforeEach to be executed for two of the blocks. Is it possible? 回答1: You can group specs which you want to run with beforeEach into a separate describe : it('should 1...', function () {}); it('should 2...', function () {}); describe('group', function () { beforeEach(function () { // ... }); it('should 3...', function () {}); it('should 4...', function () {}); //

Eslint angular and jasmine: is not defined no-undef

夙愿已清 提交于 2021-02-11 16:51:27
问题 I am trying to lint my angular code using angular, eslint:recommended and the jasmine plugin recommended settings. However I get is not defined errors on the jasmine stuff. My eslint file looks like this: { "plugins": ["jasmine"], "extends": ["angular", "eslint:recommended", "plugin:jasmine/recommended"], "rules": { "quotes": [ 2, "single"], "strict": [2, "global"], "semi": ["error", "always"], "angular/on-watch": "warn" } } I get the following errors: 3:1 error 'describe' is not defined no

How to write a Jasmine test for printer function

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 12:36:43
问题 I am trying to write a Jasmine test for the following print function: printContent( contentName: string ) { this._console.Information( `${this.codeName}.printContent: ${contentName}`) let printContents = document.getElementById( contentName ).innerHTML; const windowPrint = window.open('', '', 'left=0,top=0,width=925,height=1400,toolbar=0,scrollbars=0,status=0'); windowPrint.document.write(printContents); windowPrint.document.close(); windowPrint.focus(); windowPrint.print(); windowPrint.close

Protractor Async/Await Error: Unhandled promise rejection

时光总嘲笑我的痴心妄想 提交于 2021-02-11 07:21:04
问题 I'm refactoring my framework with protractor Async/Await to avoid sloppy browser.sleep() all over the code base. Following are the steps of test followed by code as an example: Opens ChromeBrowser Logins with the credentials Selects a customer Clicks on "Manage Customer" button. Could you please help me with below Error: Report destination: target\e2e\screenshots\my-report.html [12:42:21] I/launcher - Running 1 instances of WebDriver [12:42:21] I/hosted - Using the selenium server at http:/

Protractor Async/Await Error: Unhandled promise rejection

本秂侑毒 提交于 2021-02-11 07:21:03
问题 I'm refactoring my framework with protractor Async/Await to avoid sloppy browser.sleep() all over the code base. Following are the steps of test followed by code as an example: Opens ChromeBrowser Logins with the credentials Selects a customer Clicks on "Manage Customer" button. Could you please help me with below Error: Report destination: target\e2e\screenshots\my-report.html [12:42:21] I/launcher - Running 1 instances of WebDriver [12:42:21] I/hosted - Using the selenium server at http:/

Accessing jasmine with testRunner set to jest-circus results in: ReferenceError: jasmine is not defined

Deadly 提交于 2021-02-11 06:27:51
问题 On default jest allows you to simply access jasmine globally. But as soon as you switch the testRunner to jest-circus , jasmine is undefined. Following is a minimal, reproducible example: babel.config.js module.exports = { presets: [["@babel/preset-env", { targets: { node: "current" } }]], }; jasmine.spec.js it("check jasmine", () => { console.log(jasmine); }); jest.config.js module.exports = { rootDir: ".", testRunner: "jest-circus/runner", }; package.json { "name": "test-jest", "version":

How can I use a fake/mock/stub child component when testing a component that has ViewChildren in Angular 10+?

社会主义新天地 提交于 2021-02-10 14:33:25
问题 Before marking this as a duplicate of this question please note that I'm asking specifically about Angular 10+, because the answers to that question no longer work as of Angular 10. Background I've created a simple example app that helps illustrates my question. The idea with this app is that several "people" will say "hello", and you can respond to any or all of them by typing their name. It looks like this: (Note that the 'hello' from Sue has been greyed out because I responded by typing