Skip to content

feat: Render element tree in query error messages #1378

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

Merged
merged 24 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
55f8026
feat: Render virtual DOM in byText error message
Mar 31, 2023
1f64a25
Preserve props that hide, since relevant to failure
Mar 31, 2023
e960d91
Refactor to add props, move logic to makeQueries
Apr 4, 2023
fb9e891
Add missing tests
Apr 5, 2023
4f0389f
Optimize findBy, findAllBy to only render DOM on timeout
Apr 5, 2023
d7cf14b
refactor: make queries clean up
mdjastrzebski Apr 5, 2023
f45b242
refactor: remove color control codes from error
mdjastrzebski Apr 5, 2023
0a0bb33
refactor: disable format element coloring just for our tests
mdjastrzebski Apr 5, 2023
e5d6080
fix: host elements error message
mdjastrzebski Apr 5, 2023
1b95f4d
refactor: cleanup host component names
mdjastrzebski Apr 5, 2023
701c39e
chore: reverse unnecessary reorder of imports
mdjastrzebski Apr 5, 2023
6be5df7
refactor: tweaks
mdjastrzebski Apr 5, 2023
5c7bb55
refactor: tweaks
mdjastrzebski Apr 5, 2023
7904d3a
fix: fix issue where findBy* doesn't print tree
Apr 20, 2023
6d3d50c
refactor: update wording 'DOM' -> 'element tree'
Apr 20, 2023
8f42584
refactor: tweaks
mdjastrzebski Apr 26, 2023
4fbdda0
refactor: tweaks
mdjastrzebski Apr 26, 2023
35c3393
refactor: tweaks
mdjastrzebski Apr 26, 2023
e13c56f
refactor: restore stack change
mdjastrzebski Apr 26, 2023
eb10229
refactor: improve onTimeout error typing
mdjastrzebski Apr 26, 2023
9f81589
chore: fix lint
mdjastrzebski Apr 26, 2023
139df37
chore: increase code coverage
mdjastrzebski Apr 27, 2023
37e4aeb
chore: tweaks
mdjastrzebski Apr 27, 2023
f5f64d5
refactor: improve unit tests
mdjastrzebski Apr 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: increase code coverage
  • Loading branch information
mdjastrzebski committed Apr 27, 2023
commit 139df37ec33623af34330086522ace854c326ef4
9 changes: 9 additions & 0 deletions src/__tests__/waitFor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,12 @@ test.each([
expect(onPress).toHaveBeenCalledWith('red');
}
);

test('waitFor throws if expectation is not a function', async () => {
await expect(
// @ts-expect-error intentionally passing non-function
waitFor('not a function')
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Received \`expectation\` arg must be a function"`
);
});
9 changes: 9 additions & 0 deletions src/queries/__tests__/makeQueries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,13 @@ describe('printing element tree', () => {
</View>"
`);
});

test('does not render element tree when toJSON() returns null', () => {
const view = render(<View />);

jest.spyOn(screen, 'toJSON').mockImplementation(() => null);
expect(() => view.getByText(/foo/)).toThrowErrorMatchingInlineSnapshot(
`"Unable to find an element with text: /foo/"`
);
});
});