Comments (9)
I would be fine with a single site for all of the non codesandbox examples.
from query.
from query.
Another approach here would be to set up these examples as codesandboxes (but using the next server-side template) That way, you could easily demo/tweak them individually.
Honestly, I think I like that more. Any reason not to do that?
from query.
Going total codesandbox seems like it'd be better for users who are just evaluating the library and checking out the features. That would solve the dependency installation issues and provide a tweakable demo all at once. An argument the other way would be that keeping examples in the repo serves as documentation, of sorts. The README is already pretty robust, though..
from query.
from query.
I would love it if the docs showed an example test!
I can't for the life of me figure out how to test this. I am mocking fetch and I can see that fetch is called, and can validate the URL but the component never renders. A test example that shows how to test with this library and suspense would be awesome. I used CRA so in setupTests.js I also mock the scheduler but I'm not sure about it: jest.mock("scheduler", () => require("scheduler/unstable_mock"));
Here's my test
import React, { Suspense } from 'react';
import { render, waitForElement, cleanup } from '@testing-library/react';
// component to test
import InstagramBackground from '.';
import data from './__mocks__/data.json';
// automatically unmount and cleanup DOM after each test is finished.
afterEach(cleanup);
describe('InstagramBackground', () => {
// cleanup mocks
beforeEach(() => {
fetch.resetMocks();
});
it('it renders with suspense', async () => {
fetch.mockResponseOnce(data);
// const { getByTestId } = render(
// <Suspense fallback={<div>Not Rendered Yet</div>}>
// <InstagramBackground username="ferrytalecreative" />
// </Suspense>
// );
// const element = await waitForElement(() => getByTestId('container'));
// expect(element.toMatchSnapshot());
const { asFragment } = await waitForElement(() =>
render(
<Suspense fallback={<div>Not Rendered Yet</div>}>
<InstagramBackground username="ferrytalecreative" />
</Suspense>
)
);
// assert the snapshot matches
expect(asFragment()).toMatchSnapshot();
//assert on the times called and arguments given to fetch
expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toEqual(
'/.netlify/functions/photos?username=ferrytalecreative'
);
});
});
Update: I think I need to try this:
const {container} = render(<div>test</div>, {root: 'concurrent'}) //<-!!
expect(container).toHaveTextContent('test')
from query.
Yes, if you are trying to test concurrent mode, you'll need to configure for that. I would suggest starting with a simpler test.
As for the original purpose of this PR, is there anything new here? I would still love for the examples to be easier to access via codesandbox
from query.
@tannerlinsley Codesandbox examples in each of the example directories seems like a good middle-ground. You'd likely want to create those under your own codesandbox account, though, right?
I'll create a PR to resolve the dependency installation errors on the exisiting examples.
from query.
from query.
Related Issues (20)
- "placeholderData: keepPreviousData" results in double fetch HOT 1
- Unable to Display Previously Fetched Data in Offline Mode HOT 2
- v3 and v4 docs are unavailable HOT 2
- minimizing devtools loses offline toggle state HOT 2
- react-query-devtools: restore loading infinite wait HOT 4
- queryOptions typing errors when calling queryClient methods with ref in query key HOT 4
- Typescript incorrectly narrows `error` based on `isLoading` HOT 2
- solid-query Hydration Mismatch on SSR from version 5.24.2+ HOT 1
- Depracted warnings when installing @tanstack/react-query@latest HOT 1
- Devtools Picture-in-Picture not Working With `shadowDOMTarget` HOT 4
- getQueryData suddenly returns undefined for a query even though no update to query data has occurred HOT 1
- useSuspenseQueries inference differ from useQueries inference HOT 2
- Redundant queries invalidation when combining `useQuery` with `fetchQuery` in v5 HOT 10
- Error is reset to null during invalidation HOT 2
- UI reflection using firebase in react-query is it possible in offline mode ? HOT 1
- i have firebase + react query and i want to show data offline HOT 5
- When using PersistQueryClient, staleTime on query is not respected HOT 1
- Cached data is sometimes lost HOT 3
- Solid Query hydrates wrong query key HOT 2
- codemod: ERR_REQUIRE_ESM when migrating from v4 to v5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from query.