Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: integrate testing #54

Merged
merged 6 commits into from
Dec 11, 2024
Merged

chore: integrate testing #54

merged 6 commits into from
Dec 11, 2024

Conversation

ErikSin
Copy link
Contributor

@ErikSin ErikSin commented Dec 11, 2024

Sets up vitetest and React Testing Library

@ErikSin ErikSin requested a review from achou11 December 11, 2024 19:31
Copy link
Member

@achou11 achou11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion that I think is worth implementing before merging but otherwise changes seem reasonable

package.json Outdated Show resolved Hide resolved
Comment on lines +227 to +229
export function getUtf8ByteLength(text: string): number {
return new TextEncoder().encode(text).length
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe outside the scope of this PR but would eventually move this to something likerenderer/lib/text.ts

Comment on lines +6 to +15
vi.mock('@tanstack/react-router', () => ({
useNavigate: vi.fn(() => {
return { navigate: vi.fn() }
}),
createFileRoute: vi.fn(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (options: any) => ({ component: options.component }) // Mocked implementation
}),
Outlet: () => <div>Mocked Outlet</div>,
}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my understanding, this has to be done for each test that relies on the router in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it depends. I think short answer yes. long answer, if we want to test actual navigation actions, we need to stub out the router instead of just stubbing out the function inside the router.

I think more work needs to go into creating our mocks and stubs, but this just allows it run (its was basically a smoke screen test for jsdom)

@ErikSin ErikSin requested a review from achou11 December 11, 2024 22:06
@ErikSin ErikSin merged commit 5abf749 into main Dec 11, 2024
1 check passed
@ErikSin ErikSin deleted the chore-integrate-testing branch December 11, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants