This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:12 | |
WORKDIR /app | |
COPY ./package*.json ./ | |
RUN npm install | |
ENV PORT=4000 | |
COPY . . | |
CMD ["npm","run","start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { unmountComponentAtNode } from "react-dom"; | |
let container = null; | |
beforeEach(() => { | |
// 렌더링 컨테이너로 활용하기 위한 DOM element 를 생성합니다 | |
container = document.createElement("div"); | |
document.body.appendChild(container); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
export default function Counter() { | |
const [count, setCount] = useState(0); | |
return ( | |
<div> | |
<h1>Counter: {count}</h1> | |
<button data-testid="dec" onClick={() => setCount((count) => count - 1)}> | |
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Counter.test.js | |
import ReactDOM, { unmountComponentAtNode } from "react-dom"; | |
import { act } from "react-dom/test-utils"; | |
import Counter from "./Counter"; | |
let container = null; | |
beforeEach(() => { | |
// 렌더링 컨테이너로 활용하기 위한 DOM element 를 생성합니다 | |
container = document.createElement("div"); | |
document.body.appendChild(container); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Counter.test.js | |
import { getQueriesForElement } from "@testing-library/dom"; | |
import ReactDOM, { unmountComponentAtNode } from "react-dom"; | |
import { act } from "react-dom/test-utils"; | |
import Counter from "./Counter"; | |
let container = null; | |
beforeEach(() => { | |
container = document.createElement("div"); | |
document.body.appendChild(container); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Counter.test.js | |
import { getQueriesForElement } from "@testing-library/dom"; | |
import ReactDOM, { unmountComponentAtNode } from "react-dom"; | |
import { act } from "react-dom/test-utils"; | |
import Counter from "./Counter"; | |
let container = null; | |
export const render = (element) => { | |
container = document.createElement("div"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render } from "@testing-library/react"; | |
import Counter from "./Counter"; | |
it("Counter 컴포넌트를 렌더링합니다", () => { | |
const { getByText } = render(<Counter />); | |
getByText("Counter: 0"); | |
getByText("+"); | |
getByText("-"); |