我是webpack的新手,我需要设置一下来生成源图.我正在webpack serve
从命令行运行,它成功编译.但我真的需要源图.这是我的webpack.config.js
.
var webpack = require('webpack');
module.exports = {
output: {
filename: 'main.js',
publicPath: '/assets/'
},
cache: true,
debug: true,
devtool: true,
entry: [
'webpack/hot/only-dev-server',
'./src/components/main.js'
],
stats: {
colors: true,
reasons: true
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
'styles': __dirname + '/src/styles',
'mixins': __dirname + '/src/mixins',
'components': __dirname + '/src/components/',
'stores': __dirname + '/src/stores/',
'actions': __dirname + '/src/actions/'
}
},
module: {
preLoaders: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'jsxhint'
}],
loaders: …
Run Code Online (Sandbox Code Playgroud) Django Rest Framework序列化程序不会调用Model.clean
何时验证模型序列化程序.给出的解释是,这可以从Django Rest Framework 3.0发行说明中获得"更清晰的关注点分离" :
ModelSerializer验证和ModelForm之间的差异.
此更改还意味着我们不再
.full_clean()
在模型实例上使用该方法,而是在序列化程序上显式执行所有验证.这样可以实现更清晰的分离,并确保ModelSerializer类上没有自动验证行为,这些行为也无法在常规Serializer类上轻松复制.
但是,什么样的关注是Django的REST框架的尝试分开的作者?
我的猜测是,他们说模型实例不应该关注它自身的有效性.如果是这样的话,我不明白为什么.
python django serialization django-models django-rest-framework
我正在尝试提高针对ElasticSearch进行测试的套件的性能.
测试需要很长时间,因为Elasticsearch在更新后不会立即更新它的索引.例如,以下代码运行时不会引发断言错误.
from elasticsearch import Elasticsearch
elasticsearch = Elasticsearch('es.test')
# Asumming that this is a clean and empty elasticsearch instance
elasticsearch.update(
index='blog',
doc_type=,'blog'
id=1,
body={
....
}
)
results = elasticsearch.search()
assert not results
# results are not populated
Run Code Online (Sandbox Code Playgroud)
目前解决这个问题的解决方案是将time.sleep
调用放入代码中,以便给ElasticSearch一些时间来更新它的索引.
from time import sleep
from elasticsearch import Elasticsearch
elasticsearch = Elasticsearch('es.test')
# Asumming that this is a clean and empty elasticsearch instance
elasticsearch.update(
index='blog',
doc_type=,'blog'
id=1,
body={
....
}
)
# Don't want to use sleep functions
sleep(1) …
Run Code Online (Sandbox Code Playgroud) 如何将UITextView扩展或缩小到其中文本的大小,然后使UIScrollview展开或缩小以适应UITextView
我正在尝试使用Jest CLI测试一个promise,这个代码在浏览器中运行时应该执行.但是我想开始为它编写测试.
class ListCollection {
constructor() {
this.items = new Array();
}
addItem(string) {
const addItemPromise = new Promise(
function (resolve, reject) {
// set up async getting like a XMLHttpRequest
setTimeout( () => {
this.items.push(string);
resolve(string);
}.bind(this), 2000);
}.bind(this)
);
return addItemPromise;
}
}
Run Code Online (Sandbox Code Playgroud)
目前我正试图让这个非常基本的测试工作.我正在pit
根据链接到jasmine-pit的文档进行测试.
jest.dontMock('../collections');
import Collection from '../collections';
describe("Collection", () => {
let collection;
beforeEach(() => {
collection = new Collection();
});
describe("Adding an item", () => {
pit('Spec 1', function …
Run Code Online (Sandbox Code Playgroud) 我需要从远程URL中获取测试中的一些真实数据.我Superagent并没有被嘲笑.我已经做了,包括那个node_modules/superagent/
在unmockedModulePathPatterns
.
这是我试图测试的文件,.end()
从不调用该函数.
这是我的测试,它因超时错误而失败.
jest.dontMock("../Stocks.js");
jest.dontMock("superagent");
describe("Stock Actions", () => {
var makeRequest = require('../Stocks')
pit("doesn't crash", function () {
var promise = makeRequest("Hello World")
promise.then(function (str) {
expect(str).toBe("yay");
});
return promise;
});
});
Run Code Online (Sandbox Code Playgroud)
这是它试图测试的模块:
import Reflux from 'reflux';
import request from 'superagent';
console.log("request-superagent", request)
const makeRequest = Reflux.createAction({ asyncResult: true });
const Store = Reflux.createStore({
init() {
this.listenTo(makeRequest, 'onMakeRequest');
},
onMakeRequest(url) {
request('GET', 'http://api.example.com/list/')
.end(function (err, res) {
console.log("res.text", res.text);
if (!res.ok) {
makeRequest.failed("aw"); …
Run Code Online (Sandbox Code Playgroud) 很抱歉对社区造成了这样的负担,但我真的被困在这里了.
语义问题:使用类型NewCustomCell *
表达式初始化的不兼容指针类型UITableViewCell *
static NSString *cellID = @"customCell";
NewCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
Run Code Online (Sandbox Code Playgroud) 嗨,我正在研究Xcode和Obj-C,我收到了这个警告:
弃用:'setText:'已弃用
我想知道新方法是什么
这是我的代码:
[cell setText:[NSString stringWithFormat:@"I am cell %d", indexPath.row]];
Run Code Online (Sandbox Code Playgroud) 视图(a)包含一个子视图(b),该子视图包含一个文本标签。
文本标签的文本设置在viewDidLoad
视图(a)中。标签中的文本量会更改子视图(b)的大小。
我仅在视图(a)中获得子视图(b)的正确大小viewDidAppear
,而在中没有viewDidLayoutSubviews
。
如何在显示视图(a)的视图控制器中获取子视图(b)的大小?
更新:使用自动布局
ios ×3
objective-c ×3
xcode ×3
jasmine ×2
javascript ×2
jestjs ×2
python ×2
xcode4 ×2
ajax ×1
autolayout ×1
babeljs ×1
django ×1
ipad ×1
iphone ×1
node.js ×1
polling ×1
reactjs ×1
source-maps ×1
superagent ×1
swift ×1
testing ×1
uiview ×1
wait ×1
webpack ×1