当我将angular-route 1.5.0更新为1.5.1时,我有一个错误:
角度单位测试:错误:意外请求:GET
当我启动业力时,我有一条错误消息:
1)调用getAll方法[应用程序类别]错误:意外请求:获取http://myapp.com/app-category?is_active=true /node_modules/angular-mocks/angular-mocks.js中不再需要更多请求
app_category.model.test.js
describe('[App Category]', function () {
beforeEach(module('myApp'));
var $httpBackend, HttpService, AppCategory;
beforeEach(inject(function (_$httpBackend_, _HttpService_, _AppCategory_) {
$httpBackend = _$httpBackend_;
HttpService = _HttpService_;
AppCategory = _AppCategory_;
}));
it('Call getAll method', function () {
var app_category = new AppCategory();
HttpService.mock('GET', 'app-category?is_active=true', 200, [{ code: 'TRAVEL', name: 'Travel' }]);
app_category.getAll({ is_active: true }).then(function (request) {
expect(request.data[0].code).toBe('TRAVEL');
expect(request.data[0].name).toBe('Travel');
});
$httpBackend.flush();
});
});
Run Code Online (Sandbox Code Playgroud)
角mockHTTP.js
(function (angular) {
'use strict';
angular.module('ngMockHTTP', []).service('HttpService', function ($httpBackend, config) {
this.endpoint = config.api.endpoint; …Run Code Online (Sandbox Code Playgroud) 我想在承诺中重试我的请求.如果我总是将401错误作为循环,我想启动刷新:(如果我在刷新时有401循环,直到200)
我试过这个:
const request = require('request');
let conf = require('../conf');
let core_service = require('coreService');
let self = module.exports = {
get_count_questions: function() {
return new Promise((resolve, reject) => {
request({
method: 'GET',
uri: 'http://api/count-questions',
auth: {
'bearer': conf.token
},
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
resolve(body);
} else if (!error && response.statusCode === 401) {
core_service.refreshToken().then((data) => {
console.log('token refresh');
return self.get_count_questions();
})
} else {
reject(error);
}
})
});
} …Run Code Online (Sandbox Code Playgroud) 如何在我的功能场景中使用标签?
如何知道调用我的函数的场景?
其实我有一个场景:
Feature: create module feature
As a admin
I want to use create module
@createModule
Given I am logged as 'ADMIN'
And I am on "/admin/create"
Then The "book_id" field should be empty
Run Code Online (Sandbox Code Playgroud)
我想在我的函数中使用我的标签@createModule然后:
this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {
if (myModule === @createModule) {
...
} else if {
...
}
return main_po.checkIsEmptyElement(this, el);
});
Run Code Online (Sandbox Code Playgroud)
我想得到我的标签@createModule,以指定所调用的场景,或者其他替代方案,我想知道调用我的函数的场景.
解决了 :
我补充说:
this.Before(function (scenario, callback) {
var tags = scenario.getTags();
this.current_module = tags[0].getName();
callback();
});
Run Code Online (Sandbox Code Playgroud)
和我的功能:
this.Then(/^The …Run Code Online (Sandbox Code Playgroud) 如何使用量角器获得ng-repeat的ng-model?
<div ng-repeat="field in master.linker | orderBy:'country.name'">
<div>
<p> {{ field.country_name }} </p>
<input ng-model="field.text">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我用它,但没有成功:
var result = element.all(by.repeater('field in master.linker').column('field.text'));
result.forEach(function(entry) {
console.log(entry);
});
Run Code Online (Sandbox Code Playgroud)
我想比较一下:
result.forEach(function(entry) {
if (entry.country_name === 'en') {
expect(entry.text (from ng-repeat)).to.eventually.equal(value)
}
});
Run Code Online (Sandbox Code Playgroud) 我试图在我的视图上绑定我的模型,但是当我提交表单时我遇到了问题:我没有数组,但有很多属性.
零件 :
export class QuizFormAddQuestionComponent implements OnInit {
public question: Question;
constructor() {
this.question = new Question();
}
ngOnInit() {
this.question.setModel({ question: 'test' });
this.question.setAnswers(3);
}
createQuestion(form) {
console.log(form.value);
}
}
Run Code Online (Sandbox Code Playgroud)
我的模板:
<hello name="{{ name }}"></hello>
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-10">
<form #form="ngForm" (ngSubmit)="createQuestion(form)" class="mt-4">
<div class="form-row">
<div class="form-group col-md-12">
<label for="question" class="col-form-label">Question</label>
<input type="text"
class="form-control"
id="question"
placeholder="Enter your question..."
name="question"
[ngModel]="question.question"
required>
</div>
</div>
<div class="form-group row" *ngFor="let answer of question.answers; let i = index;">
<div class="col-sm-12"> …Run Code Online (Sandbox Code Playgroud) 我想知道如何使用 Sequelize 6 从文件中导入模型?
它适用于 "sequelize": "^5.22.0", "sequelize-cli": "^5.5.1",但我在使用 Sequelize 6 时出错。
目前,我有这个:
数据库/设置/databaseConnection.js
// Imports
import { Sequelize } from "sequelize"
const connection = new Sequelize(
process.env.DATABASE_NAME,
process.env.DATABASE_USER,
process.env.DATABASE_PASSWORD,
{
host: process.env.DATABASE_URL,
port: process.env.DATABASE_PORT,
dialect: "mysql",
logging: false,
define: {
// prevent sequelize from pluralizing table names
freezeTableName: true,
},
}
)
// Test connection
console.info("SETUP - Connecting database...")
connection
.authenticate()
.then(() => {
console.info("INFO - Database connected.")
})
.catch((err) => {
console.error("ERROR - Unable to connect to the …Run Code Online (Sandbox Code Playgroud) 如何使用javascript在客户端浏览器上修复自定义时区?
例如,在角度上我从后台有一个日期"2015-10-16T00:00:00.000Z".
我希望有一个显示器(使用UTC-4纽约或UTC + 2法国),始终:16/10/2015
阅读:
如果我在纽约使用UTC,我有:2015年10月15日.
<p ng-bind="(myDate | date:'dd/MM/yyyy')"></p>
Run Code Online (Sandbox Code Playgroud)
写:
我将日期原型修改为JSON以删除时区:
// Remove TimeZone
Date.prototype.toJSON = function(){
return moment(this).format('YYYY-MM-DD') + 'T00:00:00.000Z';
};
Run Code Online (Sandbox Code Playgroud) 如何在Jasmine和Protractor中使用Mock HTTP?
在我的test.spec.js中,我声明了一个模拟,但这个模拟不起作用.我没有任何错误.我的api总是回应,而不是模拟.
我从未见过'mockModule!' 在我的控制台中.我的功能永远不会执行:
browser.addMockModule('modName', function() {
browser.executeScript(function() {console.log('mockModule!')});
angular.module('modName', []).value('foo', 'bar').run(function ($httpBackend) {
$httpBackend.whenPOST('http://api.webapp.net/app_dev.php/module/search?direction=asc&page=1').respond('repsond');
browser.executeScript(function() {console.log('enter mockModule!')});
});
});
Run Code Online (Sandbox Code Playgroud)
在我的app.js中,我没有"ngMock".
我在index.html中添加了这个:
node_modules/angular-mocks/angular-mocks.js
Run Code Online (Sandbox Code Playgroud)
我使用'gulp protractor-local'从命令提示符运行测试:
gulp.task('protractor-local', shell.task([
'protractor protractor.conf.js --baseUrl="http://mywebapp.local.net"'
]));
Run Code Online (Sandbox Code Playgroud)
所有测试都没问题,但不是模拟.
test.spec.js
var loginPO = new(require('./models/login.model.js'))();
describe("hello", function() {
it("I click on the button-search button", function() {
loginPO.wait(10);
//browser.ignoreSynchronization = false;
browser.addMockModule('modName', function() {
browser.executeScript(function() {console.log('mockModule!')});
angular.module('modName', []).value('foo', 'bar').run(function ($httpBackend) {
$httpBackend.whenPOST('http://api.webapp.net/app_dev.php/module/search?direction=asc&page=1').respond('repsond');
browser.executeScript(function() {console.log('enter mockModule!')});
});
});
//browser.getRegisteredMockModules();
loginPO.clickButtonSearchButton();
loginPO.wait(10);
});
it("I am on the home …Run Code Online (Sandbox Code Playgroud) 如何在 Travis.yml 中使用 sudo:false 在 Travis-ci 上安装软件包?
我有我的 travis.yml :
sudo: false
install:
- wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu52_52.1-3ubuntu0.4_amd64.deb
- sudo dpkg -i libicu52_52.1-3ubuntu0.4_amd64.deb
Run Code Online (Sandbox Code Playgroud)
我有一个错误:
sudo: 必须是 setuid root
命令“sudo dpkg -i libicu52_52.1-3ubuntu0.4_amd64.deb”失败并在 .
我想知道当键盘用 React Native 打开时如何更新滚动视图?
我尝试在“ScrollView”中使用“onContentSizeChange”,没问题,但是当我打开键盘时,滚动视图不会更新(底部)
当我单击输入以发送磁带文本 (1) 时,键盘打开时滚动视图不会更新 (2)。我想更新我的滚动视图 (3)。
消息列表.js
export default class MessageList extends React.Component {
render() {
return (
<View style={MessageListStyles.container}>
<ScrollView
ref={ref => this.scrollView = ref}
onContentSizeChange={(contentWidth, contentHeight)=>{
this.scrollView.scrollToEnd({animated: true});
}}
contentContainerStyle={{
flexGrow: 1,
justifyContent: 'space-between'
}}>
<Message sender="bot" />
<Message sender="bot" />
<Message sender="bot" />
<Message sender="bot" />
<Message sender="bot" />
<Message sender="bot" />
<Message sender="bot" />
</ScrollView>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud) javascript ×7
angularjs ×4
protractor ×3
bdd ×2
node.js ×2
angular ×1
cucumberjs ×1
date ×1
docker ×1
end-to-end ×1
es6-promise ×1
jasmine ×1
object ×1
promise ×1
react-native ×1
reactjs ×1
sequelize.js ×1
travis-ci ×1
unit-testing ×1