簡體   English   中英

如何使用 typescript 為反應測試庫設置智能感知

[英]How to set intellisense for react testing library using typescript

我剛剛下載了使用反應測試庫的 Create-React-App。 當我使用它的方法時,我沒有得到智能感知(例如:toBeInTheDocument)。 如何設置智能感知? 我們有 RTL 的類型定義嗎?

import React from 'react';
import { render } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
  const { getByText } = render(<App />);
  const linkElement = getByText(/learn react/i);
  expect(linkElement).toBeInTheDocument();
});

在此處輸入圖像描述

你需要導入'@testing-library/jest-dom'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM