我需要验证一个数组以检查它的元素是否是使用 joi 的字符串。它总是发送“Inavlid tag”的错误。
// returned array from req.body
let tags = ["Vue", "React", "Angular"]
// joi shema
const schema = {
tags: Joi.array().items(Joi.string()),
};
const { error, value } = Joi.validate(tags, schema);
if (error) {
return res.status(400).send({ tagError: "Invalid tag" });
}
Run Code Online (Sandbox Code Playgroud) 对API进行一些集成测试。当断言基本相同时,其中一个测试通过,另一个测试失败。对 cypress 如何处理异步/承诺感到困惑。
context("Login", () => {
// This test fails
it("Should return 401, missing credentials", () => {
cy.request({
url: "/auth/login",
method: "POST",
failOnStatusCode: false
}).should(({ status, body }) => {
expect(status).to.eq(401) // Passes
expect(body).to.have.property("data") // Passes
.to.have.property("thisDoesntExist") // Fails
})
})
// This test passes
it("Should return 200 and user object", async () => {
const token = await cy.task("generateJwt", users[0])
cy.request({
url: "/auth/me",
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "application/json"
}
}).should(({ status, body }) …Run Code Online (Sandbox Code Playgroud) 我有login.vue一个文件,我想添加样式,我想要包含js和css文件。我不知道如何在login.vue文件中执行操作。
下面是html文件
<!DOCTYPE html>\n<html lang="en-US">\n <head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1 user-scalable=no">\n <title>Teledirect Group › Log In</title>\n <link href="css/icons.css" rel="stylesheet">\n <link rel="icon" href="img/ico/tlogofvicon.png" type="image/png">\n <link rel="stylesheet" href="css/app.css">\n <link rel="stylesheet" id="dashicons-css" href="css/dashicons.min.css" type="text/css" media="all">\n <link rel=\'stylesheet\' id=\'login-css\' href=\'css/login.min.css\' type=\'text/css\' media=\'all\' /> \n <style>\n .body_css{ \n background: #fefefe none repeat scroll 0 0;\n color: #0a0a0a;\n font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;\n font-weight: normal;\n line-height: 1.5;\n margin: 0;\n padding: 0;\n }\n </style>\n …Run Code Online (Sandbox Code Playgroud)