当用户在输入搜索中输入一些文本时,必须删除 data-testid = 'loading',现在控制台返回 Unable to find an element by: [data-testid="loading"] 有人可以建议我用 swr 或建议编写测试对我来说如何模拟来自 swr 的响应
这是我的组件文件
import axios from "axios";
import { useEffect, useState } from "react";
import useSWR from "swr";
import "./styles.css";
const useDebounce = (newValue) => {
const [value, setValue] = useState("");
useEffect(() => {
const timeout = setTimeout(() => {
setValue(newValue);
}, 500);
return () => clearTimeout(timeout);
}, [newValue]);
return value;
};
export const fetcher = async (url) => {
const { data } = await …Run Code Online (Sandbox Code Playgroud)