我在我的mac(osx lion)上安装了Jenkins.但我无法让它发挥作用.这是我得到的堆栈跟踪:
Started by user anonymous
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847
Using strategy: Default
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847
Cloning the remote Git repository
Cloning repository origin
Error trying to determine the git version: Error performing command: /usr/local/git/ --version
Cannot run program "/usr/local/git/" (in directory "/Users/Shared/Jenkins/Home/jobs/test/workspace"): error=13, Permission denied
Assuming 1.6
ERROR: Error cloning remote repo 'origin' : Could not clone git@coding-squirrel.de:iRest.git
ERROR: Cause: Error performing command: /usr/local/git/ clone -o origin git@coding-squirrel.de:iRest.git /Users/Shared/Jenkins/Home/jobs/test/workspace
Cannot run program "/usr/local/git/": error=13, Permission denied …Run Code Online (Sandbox Code Playgroud) 每个下拉选项是否可以在选择时链接到某个地方而无需外部按钮?
<select>
<option value="x">x</option>
<option value="y">y</option>
</select>
Run Code Online (Sandbox Code Playgroud) 如何检查两个日期是否在同一天.我提出了这个解决方案,但也许有更好的方法来做到这一点:
var actualDate = new Date();
var isNotToday = dateToCheck.getDay() !== actualDate.getDay() || dateToCheck < actualDate - 24 * 60 * 60 * 1000;
Run Code Online (Sandbox Code Playgroud) 我的组件测试文件中有一个这样的模拟模块
jest.mock('../../../magic/index', () => ({
navigationEnabled: () => true,
guidanceEnabled: () => true
}));
Run Code Online (Sandbox Code Playgroud)
这些函数将在我的组件的render函数中调用,以隐藏和显示一些特定的功能.
我想对这些模拟函数的返回值的不同组合拍摄快照.
假设我有一个像这样的测试用例
it('RowListItem should not render navigation and guidance options', () => {
const wrapper = shallow(
<RowListItem type="regularList" {...props} />
);
expect(enzymeToJson(wrapper)).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
运行这个测试用例我想将模块模块函数的返回值false动态更改为这样
jest.mock('../../../magic/index', () => ({
navigationEnabled: () => false,
guidanceEnabled: () => false
}));
Run Code Online (Sandbox Code Playgroud)
因为我已经导入RowListItem组件一次所以我的模拟模块不会再次导入.所以它不会改变.我怎么能解决这个问题?
我正在从摩卡交换开玩笑,我想知道是否有办法窥探反应方法.例如,假设我的组件中有以下方法(忽略sdk库,它只构造一个jquery ajax调用):
getData() {
sdk.getJSON('/someURL').done(data => {
this.setState({data});
});
}
Run Code Online (Sandbox Code Playgroud)
使用sinon我会通过监视原型来测试这个:
it('should call getData', () => {
sinon.spy(Component.prototype, 'getData');
mount(<Component />);
expect(Component.prototype.getData.calledOnce).to.be.true;
});
Run Code Online (Sandbox Code Playgroud)
这样可以确保代码覆盖而无需模拟方法.在jest中有类似的功能吗?
编辑:此外,如果此功能不存在,测试API调用的下一个最佳策略是什么?
我有一个建设者:
class Builder{
private String name;
private String address;
public Builder setName(String name){
this.name = name;
return this;
}
public Builder setAddress(String address){
this.address = address;
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
在mockito中模拟构建器会使每个方法都为null.因此,有一种简单的方法可以让构建器在每次函数调用时返回自己,而不会使用模拟每个函数本身when().thenReturn.
我用nodejs,express和htt-proxy编写了一个小代理.它适用于提供本地文件,但在代理到外部api时失败:
var express = require('express'),
app = express.createServer(),
httpProxy = require('http-proxy');
app.use(express.bodyParser());
app.listen(process.env.PORT || 1235);
var proxy = new httpProxy.RoutingProxy();
app.get('/', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
app.get('/js/*', function(req, res) {
res.sendfile(__dirname + req.url);
});
app.get('/css/*', function(req, res) {
res.sendfile(__dirname + req.url);
});
app.all('/*', function(req, res) {
req.url = 'v1/public/yql?q=show%20tables&format=json&callback=';
proxy.proxyRequest(req, res, {
host: 'query.yahooapis.com', //yahoo is just an example to verify its not the apis fault
port: 8080
});
});
Run Code Online (Sandbox Code Playgroud)
问题是雅虎api没有回复,也许有回应,但我没有在浏览器中出现.
我有一堆<a href=".html">链接,想要在新窗口中打开它们.
我知道我可以进行搜索并替换所有内容以添加target="_blank"到我的所有<a href="...">链接.
但是,是否有一种快速的方法,例如设置CSS样式或添加一些JavaScript代码来完成同样的事情?
我目前正在测试我的一个React组件,如下所示:
it('renders correctly', () => {
const tree = renderer.create(<Scene {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
我的组件Scene导入setting.json文件.我在我的本地实例上有该文件,但我没有在我的CI实例上推送它.因此,当它尝试导入它时,找不到该文件.
有没有办法在我的测试中模拟这个文件?