为了针对前端运行功能测试,我们正在考虑模拟我们的后端。不过,我们的后端迭代速度非常快并且变化很大。所以嘲笑它意味着我们总是需要知道所有的变化并相应地更新我们的模拟。
我想知道是否可以自动化这个过程。
我想为我的node.js应用程序获取Auth0持票令牌.
这样做我获得了持票人令牌:
curl https://myproject.eu.auth0.com/oauth/token --data "client_id=ID&client_secret=SECRET&type=web_server&grant_type=client_credentials"
哪个归我:
{
"access_token": *BEARER TOKEN*,
"token_type": "Bearer"
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我在Auth标题中将该标记用于邮递员,它会告诉我:
Invalid token.那么如何获得正确的承载令牌呢?
我的服务器看起来像这样:
const koa = require('koa');
const route = require('koa-route');
const jwt = require('koa-jwt');
const testRoute = require('./testRoute');
const app = koa();
//Copy pasted those values from my auth0 dashboard
const authentication = jwt({
secret: new Buffer(*CLIENT_SECRET*, 'base64'),
audience: *YOUR_CLIENT_ID*
});
app.use(authentication);
app.use(route.get('/test', testRoute));
app.listen(3000);
Run Code Online (Sandbox Code Playgroud)
我按照本指南进行设置:https://auth0.com/docs/quickstart/backend/nodejs/.
我想建立一个加载栏,一个有颜色的元素变成一个灰色的长条。
我在 CSS 方面相当糟糕,所以我在动画渐变方面遇到了一些麻烦。我目前的方法是基于这个答案:让一些渐变在 Windows 7 中的进度条中无休止地移动
foo {
background-color: $cGray300;
height: 10px;
background: linear-gradient(to right, $cGray300 0%, $cGray300 30%, #fed0d0 30%, #fed0d0 40%, $cGray300 40%, $cGray300 100%) repeat;
background-size: 50% 100%;
animation-name: moving-gradient;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@-webkit-keyframes moving-gradient {
0% { background-position: left bottom; }
100% { background-position: right bottom; }
}
Run Code Online (Sandbox Code Playgroud)
虽然我想要一个更大的红色元素,当它在右边消失时,它会重新出现在左边。
我有一种情况需要这样做:
const f = (obj) => assoc('list', createList(obj), obj)
Run Code Online (Sandbox Code Playgroud)
由于我需要第二个和第三个参数的参数,因此禁止我执行以下操作:
const f = assoc('list', somehowGetObj())
Run Code Online (Sandbox Code Playgroud)
我也试过了,但是没有用:
const f = assoc('list', createList(__))
const f = converge(assoc, [createList, identity])
Run Code Online (Sandbox Code Playgroud)
有正确的方法来通过咖喱来做到这一点吗?
我基本上想在用户将鼠标悬停在该组件上时触发该组件状态的变化。
由于onMouseEnter和onMouseLeave在某些条件下(https://github.com/facebook/react/issues/6807)无法正常工作,有没有其他选择?
编辑:我认为这与重新渲染有关。如果组件属于同一类型,但是我强制重新渲染,则会导致相同的问题。
class onHover extends Component {
constructor(props) {
super(props);
this.state = {
bool: false,
}
}
render() {
return (
<div onMouseEnter={() => this.setState({ bool: true })} onMouseLeave={() => this.setState({ bool: false })}>
{
this.state.bool ? (
<div key={Math.random()}>[OPTION1] show after onMouseEnter</div>
) : (
<div key={Math.random()}>[OPTION2] show after onMouseLeave</div>
)
}
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud) 我收到一个包含换行符 (/n)、制表符 (/t) 和小写字母 [az] 的字符串。可以通过匹配来做到这一点/\n|\t/。AFAIK 点代表通配符。
因此我想知道为什么/\n|\t/不匹配相同的东西/\\./
var text = 'test1 \ntest2';
text.split(/\n/) //['test1', 'test2']
text.split(/\./) //['test1 \ntest2']
text.split(/\\./) //['test1 \ntest2']
Run Code Online (Sandbox Code Playgroud)
不应该\\.匹配\n(换行符)吗?
我想在包含a ?或a的每个位置拆分一个字符串/.我对正则表达式不太熟悉,所以这给我带来了一些麻烦,因为我不知道在哪里和什么逃脱.它应该是这样的:
let uri = '/some/random/path?param=1234'
let arr = uri.split(/ ?|/ /);
Run Code Online (Sandbox Code Playgroud)