我正在尝试为Component编写测试,但我总是得到错误:"错误:./ExpenseOverviewComponent类中的错误ExpenseOverviewComponent - 内联模板:41:8导致:没有位置策略的提供者!"
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { FormsModule } from "@angular/forms";
import { RouterModule, Router, ActivatedRoute } from '@angular/router';
import { RouterStub, ActivatedRouteStub } from '../../../../utils/testutils';
import { HttpModule } from "@angular/http";
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { ExpenseOverviewComponent } from './expense-overview.component';
import { ExpenseFilterPipe } from '../pipes/expense-filter.pipe';
import { ExpenseService } from …Run Code Online (Sandbox Code Playgroud) 我想测试我的Angular2组件中的错误处理,因此想要模拟一个服务来返回一个Observable.throw('error').如何使用Jasmine和Karma以及Angular 2完成?
我正在使用jest-puppeteer来运行我的网络测试.如果我运行我在一个文件中定义的测试,一切都很完美.
describe('user', () => {
jest.setTimeout(12000);
beforeEach(async () => {
await page.setViewport({width: 1200, height: 2000});
await page.goTo('http://localhost:3000');
});
it('test 1', async () => {
//my test steps
});
it('test 2', async () => {
//my test steps
});
});
Run Code Online (Sandbox Code Playgroud)
但是,如果我在自己的文件中运行每个测试,我会收到错误.
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'addExpectationResult' of undefined
Run Code Online (Sandbox Code Playgroud)
文件1
describe('user', () => {
jest.setTimeout(12000);
beforeEach(async () => {
await page.setViewport({width: 1200, height: 2000});
await page.goTo('http://localhost:3000');
});
it('test 1', async () => {
//my test steps
});
});
Run Code Online (Sandbox Code Playgroud)
文件2
describe('user', () …Run Code Online (Sandbox Code Playgroud) 我有一个使用Create-React-App(react-scripts)和Material-UI的React App.我想为我的应用程序应用强大的内容安全策略,它不允许不安全的内联样式.
我想在CSP-Header服务器端设置nonce存在,这可以很容易地完成.但是,Material-UI <style>在运行时动态设置某些内联标记,而不使用nonce值作为属性.
我在指南和csp下看到了Material-UI网站上的文档.他们似乎提供了一个解决方案.但是,该解决方案是用于HTML的服务器端呈现,我没有使用它.我正在使用Create-React-App并静态地提供HTML,CSS和JavaScript.
有谁知道如何实现这一目标?
content-security-policy reactjs material-ui create-react-app
我正在尝试从sockjs-client库导入SockJS。我正在使用Aurelia和Typescript,但是在尝试将其导入时
import { SockJS } from 'sockjs-client';
Run Code Online (Sandbox Code Playgroud)
它在VS2015中说:“模块sockjs-client没有导出的成员“ SockJS””
package.json看起来像这样:
"jspm": {
"dependencies": {
//......
"sockjs": "npm:sockjs@^0.3.17",
"sockjs-client": "npm:sockjs-client@^1.1.1",
"stompjs": "npm:stompjs@^2.3.3",
},
"devDependencies": {}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
我有一个表单,其中包含所需的电子邮件类型的输入.我想在该输入字段上进行自己的自定义验证,以便能够以不同的语言显示错误消息.但是,当前输入字段由HTML5验证评估.
代码如下所示:
<input [(ngModel)]="user.email" type="email" class="form-control" id="email" name="email" required placeholder="{{'Email'|translate}}">
Run Code Online (Sandbox Code Playgroud)
是否可以禁用它,以便我能够实现自己的验证?
验证码尚未编写.
我想使用 Recharts 的 LineChart 来显示最多 200 个点的数据集。但是,我只想在小屏幕上显示其中 5 个数据点的 dots/tooltip/activeDot,因为 200 个点在智能手机上不再可点击。
我怎样才能做到这一点?
我在Gitlab中有一个可通过HTTP/SSH获得的项目:
git@192.168.1.10:MyGroup/MyProject.git
Run Code Online (Sandbox Code Playgroud)
我想用另一个IP来改变它,即:
git@192.168.1.20:MyGroup/MyProject.git
Run Code Online (Sandbox Code Playgroud)
我在哪里或如何改变?
我有以下HTML和CSS片段,我想要"!" 不要强调,但确实如此.我究竟做错了什么?
p {
color:red;
text-decoration:
underline;
font-size: 1.2em;
}
span.none {
text-decoration: none;
}Run Code Online (Sandbox Code Playgroud)
<p class="p">Click the thumb<span class="none">!</span></p>Run Code Online (Sandbox Code Playgroud)
我想对我的基于 express 的节点应用程序使用 Brotli 压缩。我使用app.use(express.static('public')).
我找到了shrink-ray完美地进行 Brotli 压缩的模块。但是,当我安装它并nsp check从节点安全平台模块运行它时,我得到了安全漏洞,这使得它无法在我的项目中使用。
有没有人知道使用 express 在节点应用程序上启用 Brotli 压缩的好方法?我试过express-static-gzip但没能成功,即使在一个简单的教程中它仍然被压缩。
我想将字符串文字传递给单击处理程序的方法.
<button (click)="changeLanguage("en")">EN</button>
Run Code Online (Sandbox Code Playgroud)
它不像上面那样工作.怎么能实现这一目标?
angular ×4
typescript ×3
html ×2
jasmine ×2
karma-runner ×2
aurelia ×1
brotli ×1
css ×1
e2e-testing ×1
express ×1
git ×1
gitlab ×1
gitlab-ci ×1
html5 ×1
javascript ×1
jestjs ×1
material-ui ×1
node.js ×1
puppeteer ×1
reactjs ×1
recharts ×1
sockjs ×1
validation ×1
web-testing ×1
webpack ×1
webtest ×1