jasmine

初学Web前端开发,弄懂这些细节,工作后薪资爆表!

孤街浪徒 提交于 2020-02-25 18:31:16
曾经的我怎么也想不到,web前端开领域能发展到今天的样子,但是对于很多想转行学习的初学者,你首先需要先掌握必备的基础知识,以及独立学习及解决问题的技能。下面我们来详谈一下!坐下来详谈 地基-基础:HTML、CSS 和 JavaScript-----网页三剑客 在一开始一个初学者都是蒙圈的状态,不知道自己该学什么是正常的,首先你需要先了解 HTML、CSS 以及 JavaScript 的基本语法,这好比我们盖房子打下的地基,地基有多么牢靠,房子就能盖多高,地基打好了,房子就会变成楼房,学习HTMLCSS是非常容易的,在有人正确指导学习下利用1.5个月的时间就可以完全熟练的掌握网页的静态布局,我接触过很多初学者,一周就把HTMLCSS学完了,过来人告诉你不仅“一点用处没有”而且大大浪费时间,不过每个人的选择都不一样。 接下来我们通过一些练习巩固基本语法,并通过实际编写项目来对其进行掌握和探索,完成3-5个成型的静态界面,穿插知识点融会贯通,最后你需要一些比较好的书籍进行理论知识的灌溉进阶的指导来帮助你深入理解概念。在这个时候一定要记住,书是后面看的,一定不要先看书, 以 JavaScript 为例 首先我们需要了解 变量 、 赋值 、 运算符 、 布尔值 、 循环 、 数组 、 函数 等基本语法,并通过写一些 快速反馈 的习题来帮助自己掌握语法。 接着我们可以编写一些交互式的操作

Cannot read property 'afterClosed' of undefined when unit testing MatDialog in Jasmine

血红的双手。 提交于 2020-02-24 12:38:32
问题 I get the following error from Karma Jasmine: TypeError: Cannot read property 'afterClosed' of undefined I searched sincerely, but I could not find a solution in Stack Overflow or in other sources. This is how I open the MatDialog in my component: (Like documented) constructor(public dialog: MatDialog) {} public openDialog(): void { const dialogReference: MatDialogRef<any, any> = this.dialog.open(myDialogComponent, { width: '1728px' }); dialogReference.afterClosed().subscribe((result) => { })

Cannot read property 'afterClosed' of undefined when unit testing MatDialog in Jasmine

余生长醉 提交于 2020-02-24 12:38:09
问题 I get the following error from Karma Jasmine: TypeError: Cannot read property 'afterClosed' of undefined I searched sincerely, but I could not find a solution in Stack Overflow or in other sources. This is how I open the MatDialog in my component: (Like documented) constructor(public dialog: MatDialog) {} public openDialog(): void { const dialogReference: MatDialogRef<any, any> = this.dialog.open(myDialogComponent, { width: '1728px' }); dialogReference.afterClosed().subscribe((result) => { })

[Unit Testing] Jasmine Spies

人走茶凉 提交于 2020-02-10 03:08:48
it ('should add two numbers', () => { const logger = jasmine.createSpyObj('LoggerService', ['log']) // logger.log.and.returnValue();   const calculator = new CalculatorService(logger) const result = calculator.add(2,2) expect(result).toBe(4) expect(logger).toHaveBeenCalledTimes(1) }) 来源: https://www.cnblogs.com/Answer1215/p/12289683.html

Unit testing - Getting issue with Alert Controller in Ionic Framework

十年热恋 提交于 2020-02-06 20:26:52
问题 I am trying to write a testcase for a method which has been called or not. Inside that method, I am calling an alert confirmation box. I am getting an error like Failed: this.alertCtrl.create is not a function Component.ts submitTicket(comments) { if (comments.length > 0) { const prompt = this.alertCtrl.create({ title: "<span> Improve Solution </span>", message: "<span>" + 'Are you sure you want <br>' + "</span>" + "<span>" + 'to submit this improvement' + "</span>", enableBackdropDismiss:

How to test _.defer() using Jasmine, AngularJs

泄露秘密 提交于 2020-01-30 03:11:53
问题 I already asked this question where the main point was scope doesn't exists in terminal but it exists in Chrome debugging tool. Despite the answers it didn't get fixed. The question is what is the right syntax to test the bellow directive, especially the line expect(scope.measurementScroll).toBe(true); . While digging through web i couldn't find any similar question most questions are related to $q.defer() where in my case there is underscore method _.defer() Controller 'use strict'; angular

Mocking jQuery ajax calls with Jasmine

寵の児 提交于 2020-01-25 22:02:29
问题 I am using Jasmine 2.5.2 to write unit tests for code that performs Ajax requests using jQuery 3.1.1 . I would like to mock out the Ajax call, providing my own response status and text. I am using the Jasmine ajax plug-in (https://github.com/pivotal/jasmine-ajax). Following the example on https://jasmine.github.io/2.0/ajax.html, which uses the XMLHttpRequest object, works fine. describe("mocking ajax", function() { describe("suite wide usage", function() { beforeEach(function() { jasmine.Ajax

Execute code after Jasmine test failure

两盒软妹~` 提交于 2020-01-24 03:58:25
问题 Is it possible to do something only if a Jasmine test fails? Juxtaposed with afterEach() which executes after an it() regardless of outcome, I'm looking for some way to execute code only after an it() has a failed expectation. This question is not Angular-specific, but in my scenario I am testing an Angular service which outputs debug messages using $log . I don't want to clutter my console for tests that are successful, but only show the additional information for failing tests. describe(

Testing focus() on an element in an AngularJS directive template

戏子无情 提交于 2020-01-24 03:50:46
问题 Given the following directive directive('myDirective', function() { return { restrict: 'A', scope: {}, replace: false, template: '<input ng-focus="onFocus()" type="text" />', link: function(scope, element, attr) { scope.onFocus = function() { console.log('got focus'); }; } }; }); I've tested that the focus watcher works in a browser, but I'd like to be able to trigger it in a unit test. This is what I've tried but it isn't working. var element = angular.element('<div my-directive></div>');

Using TypeMoq Mock With Angular TestBed

只愿长相守 提交于 2020-01-24 02:50:21
问题 I've defined a FooService as follows import {Injectable} from "@angular/core"; export interface Foo { Foo(): string; } @Injectable() export class FooService implements Foo { Foo(): string { return "Fooey!"; } } and a BarComponent like this import {Component} from "@angular/core"; import {FooService} from "./foo.service"; @Component({ moduleId: 'module.id', template: '<h1>Bar Component</h1>' }) export class BarComponent { constructor(private fooService: FooService) {} doFoo(): string { return