在Cypress.io测试中,我正在调用减法函数并以“ example-spec”形式编写测试,如下所示。一切正常。但是,我们如何调用在不同js文件中编写的相同减法函数,例如赛普拉斯测试中的'/basetest.js'?
describe ('Calling a function', function(){
it('Call the Subtract function and asert the calculation', function(){
cy
.wrap({sub: subValues})
.invoke('sub', 15, 8)
.should('eq', 7) // true
})
})
Run Code Online (Sandbox Code Playgroud)
//减去函数:
const subValues = (a, b) => {
return a - b
}
Run Code Online (Sandbox Code Playgroud) 在Cypress.io测试中,在应用过滤器后检查表中显示的“数据”时,它抛出“ CypressError:超时重试:无法读取未定义的属性'eq'”。有人可以在下面的测试中建议如何解决问题吗?下面添加了表格HTML图像。
describe('Filter Test', function() {
it.only('Check if the records are filtered successfully', function() {
cy.visit('http://www.seleniumeasy.com/test/table-search-filter-demo.html')
cy.get('button').contains('Filter').click()
cy.get('input[placeholder="Username"]').type('jacobs')
cy.get('table').should(($tr) => {
const $tds = $tr.find('td') // find all the tds
expect($tds.cells.eq(0)).to.contain('jacobs')
})
})
})
Run Code Online (Sandbox Code Playgroud)
我已经开始学习关于React js. 现在我正在构建一个博客页面,理想情况下是使用React.js. 有没有一种有效的方法来创建一个简单的 3 列布局,我可以style在其中设置列。在components文件夹下创建了一个App.js文件并使用Blog.js、BlogItem.js创建了文件,但是如何在React.js中传递3列结构布局?请指教
// App.js :
import React, {Component}from 'react';
import Blog from './components/Blog'
import './App.css';
class App extends Component {
state={
blogs:[
{
id: 1,
title:'Javascript blog',
completed: false
},
{
id: 2,
title:'Cypress blog',
completed: false
},
{
id: 3,
title:'Testing blog',
completed: false
},
{
id: 4,
title:'Java multi threading blog',
completed: false
},
{
id: 5,
title:'Puppeteer blog',
completed: false
},
{
id: 6,
title:'React Examples',
completed: …Run Code Online (Sandbox Code Playgroud) 例如,如果我给出完整的类名:title-text-panel-container class-about-benefits > ulcypress 无法识别该元素并抛出以下错误 C ypressError: Timed out retrying: Expected to find element: '.title-text-panel-container class-about-benefits > ul' ,但一直没有找到。为什么 cypress 无法识别我们是否full class name在测试中屈服?但它通过了测试,因为我们按照测试 2 给出了类名。
测试 1: 失败
cy.get('.title-text-panel-container class-about-benefits > ul').find('li').its('length').should('be.gte', 1);
Run Code Online (Sandbox Code Playgroud)
测试:2次通过
cy.get('.title-text-panel-container > ul').find('li').its('length').should('be.gte', 1);
Run Code Online (Sandbox Code Playgroud)
使用React hooks如何在previewProfilePic > img通过选择文件输入上传图像后预览区域下的图像。
import React, { useState } from "react";
const Register = () => {
const [picture, setPicture] = useState(null);
const onChangePicture = e => {
console.log('picture: ', picture);
setPicture(e.target.files[0]);
};
return (
<div className="register_wrapper">
<div className="register_player_column_layout_one">
<div className="register_player_Twocolumn_layout_two">
<form className="myForm">
<div className="formInstructionsDiv formElement">
<h2 className="formTitle" >Sign Up</h2>
<p className="instructionsText"></p>
<div className="register_profile_image">
<input id="profilePic" type="file" onChange={onChangePicture}/>
</div>
<div className="previewProfilePic" >
<img className="playerProfilePic_home_tile" src=""></img>
</div>
</div>
<div className="fillContentDiv formElement">
<div className="names formContentElement">
<input className="inputRequest " …Run Code Online (Sandbox Code Playgroud) 我正在contentful我的 React Hooks 网站中显示博客内容。现在博客的完整描述已收到post.description。我想将code snippets, json datapost.description 中收到的内容显示为code block。还想将标题行添加到 h1 或 h2 标签。我们如何从描述字段中识别代码块?现在它只显示页面中的文本(请参阅添加的屏幕截图)
import React from "react";
import { Link, useParams } from "react-router-dom";
import MD from "react-markdown";
import { useSinglePost } from "../custom-hooks";
import Moment from 'moment';
export default function SinglePost() {
const { id } = useParams();
const [post, isLoading] = useSinglePost(id);
const renderPost = () => {
if (isLoading) return ( <div> <p className="noSearchData">Loading...</p> </div>);
return (
<React.Fragment>
<div …Run Code Online (Sandbox Code Playgroud) 我用来git add . 添加所有文件,即修改后的新文件,并且不删除文件。但是在使用这个时,它untracked也接受所有文件。是否有一个命令可以与 结合使用git add .来忽略未跟踪的文件。?
git 版本:Windows 10 上的 2.28.0 :
git status
git add . *single command to combine with git add . to ignore untracked files*
git commit -m"commit message"
git push
Run Code Online (Sandbox Code Playgroud) 我已在服务器中部署了我的反应应用程序Vultr并安装nginx在服务器中,并通过运行以下命令配置了以下设置。
$ sudo nano /etc/nginx/sites-available/default
server {
listen 80;
server_name somedomain-test.com www.somedomain-test.com;
root /var/www/somedomain-test.com/build;
index index.html;
}
Run Code Online (Sandbox Code Playgroud)
我确实运行npm run build并将构建文件夹复制到以下目标文件夹中/var/www/automateandmore.com/build
然后运行以下命令:
$ sudo nginx -t
$ sudo systemctl restart nginx
Run Code Online (Sandbox Code Playgroud)
我能够看到前端。server.js现在我已经从文件夹位置启动了src/,但我仍然可以看到它正在调用localhost:8000/service/listofblogs:
我该如何解决这个问题,有人可以建议吗?
这是我的 package.json 设置
{
"name": "myblogs",
"version": "0.1.0",
"private": true,
"dependencies": {
.....
},
"proxy": "http://localhost:8000",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
....
}
}
Run Code Online (Sandbox Code Playgroud)
.env 文件 …
javascript ×4
cypress ×3
reactjs ×3
react-hooks ×2
contentful ×1
git ×1
nginx ×1
nginx-config ×1
vultr ×1