jasmine

How do I add svg files via MatIconRegistry in unit tests?

左心房为你撑大大i 提交于 2020-06-10 03:42:29
问题 I'm currently implementing 'unit testing' in my angular application. However, if I run them, I receive multiple warnings/errors similar to this one: 'Error retrieving icon: Unable to find icon with the name ":myIcon"' . I suspect it might be caused by not adding the svgs to my MatIconRegistry. I usually do this in my AppComponent, like so: constuctor(private iconRegistry: MatIconRegistry, private sanitizer: DomSanitizer, ...) { iconRegistry.addSvgIcon('myIcon', sanitizer

How do I add svg files via MatIconRegistry in unit tests?

旧城冷巷雨未停 提交于 2020-06-10 03:41:11
问题 I'm currently implementing 'unit testing' in my angular application. However, if I run them, I receive multiple warnings/errors similar to this one: 'Error retrieving icon: Unable to find icon with the name ":myIcon"' . I suspect it might be caused by not adding the svgs to my MatIconRegistry. I usually do this in my AppComponent, like so: constuctor(private iconRegistry: MatIconRegistry, private sanitizer: DomSanitizer, ...) { iconRegistry.addSvgIcon('myIcon', sanitizer

right click in protractor

[亡魂溺海] 提交于 2020-06-08 20:08:41
问题 I'm trying to right click an element using protractor, the element is a cell in an ag-grid. I'm trying to use some of the earlier suggestions that I could find, the only one that didn't throw me an error was the following: browser.actions().mouseMove(elementVar).perform(); browser.actions().click(protractor.Button.RIGHT).perform(); although it doesn't right-click at all. Any suggestions? 回答1: From the webdriverJs api, you can right click an element thusly: browser.actions() .click($('.myElm')

right click in protractor

北战南征 提交于 2020-06-08 20:08:38
问题 I'm trying to right click an element using protractor, the element is a cell in an ag-grid. I'm trying to use some of the earlier suggestions that I could find, the only one that didn't throw me an error was the following: browser.actions().mouseMove(elementVar).perform(); browser.actions().click(protractor.Button.RIGHT).perform(); although it doesn't right-click at all. Any suggestions? 回答1: From the webdriverJs api, you can right click an element thusly: browser.actions() .click($('.myElm')

Angular testing - observable pipe is not a function

回眸只為那壹抹淺笑 提交于 2020-05-30 07:13:42
问题 I want to write a unit test for a photo-upload-mehtod. But I get the Failed: this.task.snapshotChanges(...).pipe is not a function TypeError: this.task.snapshotChanges(...).pipe is not a function Error. For the sake of simplicity of this question, I put the code all in one method: Component public startUpload(event: FileList) { const file: File = event.item(0); const pathRef = `users/${this.uid}`; this.task = this.service.uploadPhoto(pathRef, file); this.fileRef = this.service

Angular Testing - Mocking An InjectionToken

元气小坏坏 提交于 2020-05-29 10:22:29
问题 I'm trying to test an Angular service that handles SignalR connections, which takes the code for SignalR as an InjectionToken. Here's the provider file: // signalr-provider.ts import { InjectionToken } from '@angular/core'; export const SIGNALR_TOKEN = new InjectionToken('signalR'); export function signalRFactory() { return window['signalR']; } export const SIGNALR_PROVIDER = [ { provide: SIGNALR_TOKEN, useFactory: signalRFactory } ]; And here's the service: // signalr-service.ts import {

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

Get currently executed describe/test name

余生长醉 提交于 2020-05-26 11:41:06
问题 is it possible with jest(jasmine) to ge the currently executed name of the test or describe inside the test? Using Jasmine: How to get name of current test is not working anymore or at least with jest. e.g. test('Error missing body', (done) => { console.log('Currently executing: ' + REFERENCE_TO_TEST_NAME); done(); }); Thanks 回答1: const testParam = 'any text you need'; describe(`${testParam}`, () => { test('mind the backtick', () => { console.log(`Currently executing: ${testParam}`); }); });

Eslint angular and jasmine: is not defined no-undef

一笑奈何 提交于 2020-05-23 12:13:23
问题 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

Testing: blur emulate

﹥>﹥吖頭↗ 提交于 2020-05-15 10:04:53
问题 I would like to test simple angular component with input. So an example in the bottom has little preparation for the test, and in a component should occur test function on blur, which shows log, but I have no logs in console. I tried 2 cases: getting div native element and click it and use blur() function for input native element. In angular app blur successfully occur, but it doesn't work in test. How can I fix it? @Component({ template: '<div><input [(ngModel)]="str" (blur)="testFunc($event