我正在使用以下jest.unittest.json文件(通过jest --config选项使用):
{
"bail": false,
"verbose": true,
"transform": {
"^.+\\.(ts|tsx)$": "typescript-babel-jest"
},
"testPathIgnorePatterns": [
"<rootDir>/lib",
"<rootDir>/lib_es6",
"/node_modules/",
"fixtures.ts",
"/fixtures/"
],
"moduleFileExtensions": [
"js", "jsx", "ts", "tsx", "node"
],
"roots": [
"<rootDir>/src/__unittests__/Logger",
"<rootDir>/src/__unittests__/Renderer/renderer.test.ts"
],
"testRegex": "<rootDir>/src/__unittests__/.*\\.test.(ts|tsx|js|jsx)$"
}
Run Code Online (Sandbox Code Playgroud)
请注意,测试文件是src/unittests /Renderer/renderer.test.ts,依此类推.
它曾经工作到jest v19,但升级到v20后,此配置不再有效.
当我做jest --config jest.unittest.json --verbose时,我得到:
Pattern: "" - 0 matches
我的配置有什么问题吗?
我正在尝试使用生成器创建一个promise-wrapper,以便我可以:
var asyncResult = PromiseWrapper( $.ajax( ... ) );
Run Code Online (Sandbox Code Playgroud)
到目前为止,我一直在尝试:
function PromiseWrapper(promise){
return function *wrapper(promise){
promise.then(function(result){
yield result;
}, function(err){
throw err;
});
}(promise).next().value
}
Run Code Online (Sandbox Code Playgroud)
但这失败了,因为不允许在法线内屈服.这有什么解决方法吗?谢谢你:D
ps:我正在使用babel将代码从es6转换为es5
我正在关注udacity的"开发Android应用程序"课程.我在Lesson4A上遇到问题,测试套件(TestUtilities)抱怨"在'根项目'阳光'中找不到"任务'cleanTest'.然后它指出我使用--stacktrace选项运行.
但我不知道如何在终端上运行命令.如何查看android studio正在运行的gradle-tasks?谢谢 :)
我正在使用 Android Studio,并且布局 xml 缩进对我来说以某种错误的方式自动格式化。
代替
<!-- case1: miss-diffs on git -->
<SomeXML
attr1="hello" >
</SomeXML>
Run Code Online (Sandbox Code Playgroud)
或者
<!-- case2: wrong end(?) indentation level -->
<SomeXML
attr1="world"
>
</SomeXML>
Run Code Online (Sandbox Code Playgroud)
我想将我的 xml 格式化为
<SomeXML
attr1="hello"
>
</SomeXML>
Run Code Online (Sandbox Code Playgroud)
这样我的 git diff 就不会显示 case1 中的任何未命中差异,并且没有错误的缩进级别(case2)来混淆我自己。
intellij 中是否有任何选项?提前致谢 : )
有什么方法可以设置所有 HTMLSourceElements 的 src 属性的 getters 和 setters 吗?我正在考虑使用它作为我的网络应用程序的额外安全措施,该应用程序使用来自其他网站的 JS。通过“所有 HTMLSourceElements 的 src 属性的设置器”,我的意思是应该在以下代码上调用设置器:SomeVideoElement.src =“/static/somevideo.mp4”
到目前为止,我已经尝试过:
HTMLElement.prototype.__defineGetter__("src", function () {
console.log("getter called!");
debugger;
});
HTMLElement.prototype.__defineSetter__("src", function (val) {
debugger;
});
//tested at chrome, didn't yield any logs (getters and setters not called)
Run Code Online (Sandbox Code Playgroud)
和
HTMLSourceElement.prototype._setAttribute = HTMLSourceElement.prototype.setAttribute;
HTMLSourceElement.prototype._getAttribute = HTMLSourceElement.prototype.getAttribute;
HTMLSourceElement.prototype.setAttribute = function(){
console.log("HTMLSourceElement.setAttribute called!");
debugger;
HTMLSourceElement.prototype._setAttribute.apply(this, arguments);
}
//tested at chrome. Called only for codes like: SomeVidElem.setAttribute("src",someurl)
Run Code Online (Sandbox Code Playgroud)
有什么办法可以做到这一点吗?或者这根本不可能?谢谢 : )
android ×2
javascript ×2
babel-jest ×1
ecmascript-6 ×1
es6-promise ×1
generator ×1
html ×1
jestjs ×1
xml ×1