我创建了一个应用程序,create-react-app
并在Jest + Istanbul中编写了一些UI测试.
我想获得这些UI测试的代码覆盖率.我喜欢继续使用jest,因为我已经将它用于单元测试.
create-react-app
如果可能的话,我不想弹出.但如果别无选择,我会对此持开放态度.
到目前为止我尝试过的:
在 package.json
"scripts": {
"uitest": "react-scripts test --env=jsdom --verbose --testMatch='**/*.ui-test.{js}'",
}
Run Code Online (Sandbox Code Playgroud)
如果我跑 npm run uitest -- --coverage
^我认为在上面的场景中它只捕获测试而不是实际的App.
我该如何解决?
其他尝试失败:
1)如何覆盖伊斯坦布尔的React jsx文件? - 不要像我使用的那样申请create-react-app
2)https://github.com/facebook/create-react-app/issues/3257 - 显然这个功能被提出但被拒绝了.
3)https://github.com/istanbuljs/puppeteer-to-istanbul/issues/18 - 有一个名为puppeteer-to-istanbul的库,但它不支持源映射.(参见问题链接)
4)我也查看了关于safaribooks的Node.js Web开发 - 第四版的书 - 我找到了一个有用的Puppeteer指南,但它似乎没有涵盖,代码覆盖率.
5)在safaribooks上预订动手持续集成和交付 - 有一个关于Puppeteer + Jest测试的部分,没有说明代码覆盖率.
6)我试过puppeteer-to-istanbul
- >我们可以通过这种方式计算bundle的代码覆盖率,它不支持源映射.
7)尝试了Enselic的建议,但无法使其正常工作.push
尝试推送时,它似乎在自定义预设中的方法崩溃babel-plugin-istanbul
.
我正在尝试使用JavaFX编写拼图游戏,部分原因是有人问我,部分是因为我想给JavaFX一个机会.但是,我对图像的实际裁剪有困难.
该想法是供用户提供图像和程序以将图像切割成更小的片段.简单吧?我的问题是:我能找到切割图像的唯一方法是制作图像对象的副本并更改副本的可见部分,这是一个例子:
ImageView imgageView = new ImageView(); // Creates a new ImageView; this will be a single puzzle piece.
imgageView.setImage(originalImage); // Use the original image as the "base."
Rectangle2D rectangle = new Rectangle2D(0, 0, 50, 50); // Crop the image from (0,0) to (50, 50).
Run Code Online (Sandbox Code Playgroud)
public Rectangle2D(double minX,
double minY,
double width,
double height)
Creates a new instance of Rectangle2D.
Parameters:
minX - The x coordinate of the upper-left corner of the Rectangle2D
minY - …
Run Code Online (Sandbox Code Playgroud) 我查看了at4j和7-Zip-JBinding(他们的javadoc和文档),但是他们似乎无法在没有解压缩的情况下读取(并从归档文件中获取InputStream)
有什么方法我缺少或找不到?
除了提取到临时文件夹以读取它之外的解决方案
我期待在at4j或7-Zip-JBinding中如何做到这一点的答案
换句话说,我想知道如何在at4j或7-Zip-JBinding中使用下面提到的函数
我知道java内置了一个getInputStream,我现在正在使用它
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
* get input stream of current file
* @param path path inside zip
* @return InputStream
*/
public InputStream getInputStream(String path){
try {
ZipEntry entry = zipFile.getEntry(path);
if(entry!=null){
return zipFile.getInputStream(entry);
}
return new ByteArrayInputStream("Not Found".getBytes());
} catch (Exception ex) {
//handle exception
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
(^^ zipFile是一个ZipFile对象)