• 카테고리

    질문 & 답변
  • 세부 분야

    데브옵스 · 인프라

  • 해결 여부

    미해결

테스트 실행 시 fail이 발생하는데 왜 그런걸까요??ㅜㅜ

20.10.13 12:20 작성 조회수 1.07k

0

안녕하세요. 테스트 진행 중에 fail이 발생해서 왜 그런지 잘 모르겠습니다. 

아래는 fail 로그예요

 FAIL  src/App.test.js

  ✕ renders learn react link (42ms)

  ● renders learn react link

    Unable to find an element with the text: /learn react/i. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

    <body>

      <div>

        <div

          class="App"

        >

          <header

            class="App-header"

          >

            <img

              alt="logo"

              class="App-logo"

              src="logo.svg"

            />

            <p>

              Edit 

              <code>

                src/App.js

              </code>

               and save to reload.

            </p>

            <a

              class="App-link"

              href="https://reactjs.org"

              rel="noopener noreferrer"

              target="_blank"

            >

              반갑습니다.

            </a>

          </header>

        </div>

      </div>

    </body>

       5 | test('renders learn react link', () => {

       6 |   const { getByText } = render(<App />);

    >  7 |   const linkElement = getByText(/learn react/i);

         |                       ^

       8 |   expect(linkElement).toBeInTheDocument();

       9 | });

      10 | 

      at Object.getElementError (node_modules/@testing-library/dom/dist/config.js:34:12)

      at node_modules/@testing-library/dom/dist/query-helpers.js:71:38

      at getByText (node_modules/@testing-library/dom/dist/query-helpers.js:54:17)

      at Object.<anonymous> (src/App.test.js:7:23)

Test Suites: 1 failed, 1 total

Tests:       1 failed, 1 total

Snapshots:   0 total

Time:        1.958s

Ran all test suites.

답변 1

답변을 작성해보세요.

0

왜냐면   learn react 라는 글짜가  렌더링 하는 jsx 안에 있어야 하는 데 없어서 그런겁니다 .  
저 테스트 부분을 없애고 진행해주세요 ^^