// describe - 대주제, 설명, 묘사하다
describe('메인 테스트', () => {
// it - 테스트할 기능 대상
it('1. 메인 페이지로 이동', () => { // 테스트 설명 제목
cy.visit('http://localhost:3000');
});
it('2.', () => {
// cy.get('selector').contains('innerHtml'); // 문자열이 포함된 것을 찾음
cy.contains('회원가입').click();
})
...
});
// Home.tsx
function Home() {
const article = {
author: {
username: 'Gerome',
image: 'https://api.realworld.io/images/demo-avatar.png',
},
createdAt: 'Wed Nov 24 2021',
favoriteCount: 452,
title: 'Create a new implementation',
description: 'join the community by creating a new implementation',
tags: ['implementations'],
};
return (
<div id="main">
<div data-reactroot="">
<NavBar />
<ArticlePreview {...article} />
...
</div>
</div>
);
}
export default Home;
// ArticlePreview.tsx
import React from 'react';
interfacee ArticlePreviewProps {
// username: string, image: string -> 공통
author: {
username: string;
image: string;
};
createdAt: string;
...
// tags: string[];
tags: Array<string>;
}
// 구조분해 할당 https://ko.javascript.info/destructuring-assignment
const ArticlePreview = ({
author,
createdAt,
favoriteCount,
title,
description,
tags,
}: ArticlePreviewProps) => {
return (
...
);
}
2.1 필요한 프로그램 설치
git --version
입력2.2 사용자 설정 및 필요한 셋팅들
git config --list
를 작성해 설정들을 확인할 수 있음.git config --global user.name "v"
git config --global user.email "v@email.com"
// 설정 확인
git config user.name
// git 명령어 -option
git commit -m ""
2.4 깃 초기화 하고 삭제하기
git init
rm -rm git
import React, { useState } from 'react';
const EventPractice = () => {
const [form, setForm] = useState({
username: '',
userId: ''
});
const { username, userId } = setForm;
const onChange = (e) => {
const { name, value } = e.target;
setForm({
// 불변성..?
...form, // 기존의 form
[name]: value // js object key에 []를 쓰는 이유가 뭐였지?!
});
};
return (
<form>
<input
type="text"
name="username"
placeholder="이름"
value={username}
onChange={onChange}
/>
<input
type="text"
name="userId"
placeholder="아이디"
value={userId}
onChange={onChange}
/>
</form>
);
}