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

feat: debug options #1160

Merged
merged 27 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aff4939
chore: clear mocks automatically for better tests isolation
Oct 6, 2022
c13eb6a
feat: add filterProps option for debug function
Oct 6, 2022
49605af
chore: update flow types for debug
Oct 12, 2022
b90dafa
refactor: break test into several ones
Oct 14, 2022
b55544e
feat: add debugOptions to global config
Oct 14, 2022
11ebc17
docs: update website docs with new api
Oct 14, 2022
c7bbf2b
feat: add mapProps to debugOptions instead of filterProps
Oct 31, 2022
a725989
chore: add migration warning if older debug api is used
Oct 31, 2022
bcd43f3
chore: change order in options debugoptions union type
Oct 31, 2022
7335349
refactor: rename option for debugOptions in config to match dtl naming
Oct 31, 2022
b257149
chore: silence deprecation warning in tests
Oct 31, 2022
d8b0c75
docs: update website docs with new debug option
Oct 31, 2022
0d15e55
Update deprecation warning in src/render.tsx
pierrezimmermannbam Nov 2, 2022
cc00d75
fix: update flow type for defaultdebugoptions
Nov 2, 2022
9012e0f
refactor: apply mapProps option only to reactTestElement plugin
Nov 2, 2022
3ce8323
refactor: delete obsolete test on mapProps option
Nov 2, 2022
0126c7c
tests: remove implicit assertion in tests and write a specific test
Nov 2, 2022
78e1104
refactor: apply review suggestions
Nov 2, 2022
bfe1d72
docs: improve debug doc based on review and add more examples
Nov 2, 2022
376b6d7
refactor: etract debug tests to separate file
mdjastrzebski Nov 3, 2022
555be44
docs: small fixes
mdjastrzebski Nov 3, 2022
416d1ea
docs: remove typeEmail example
mdjastrzebski Nov 3, 2022
d862428
docs: tweaks
mdjastrzebski Nov 3, 2022
240aa67
docs: tweaks
mdjastrzebski Nov 3, 2022
2e94290
docs: tweaks
mdjastrzebski Nov 3, 2022
32bddce
docs: tweaks
mdjastrzebski Nov 3, 2022
f560898
fix: json output mutation by `format` function
mdjastrzebski Nov 3, 2022
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"testTimeout": 60000,
"transformIgnorePatterns": [
"/node_modules/(?!(@react-native|react-native)/).*/"
]
],
"clearMocks": true
mdjastrzebski marked this conversation as resolved.
Show resolved Hide resolved
}
}
218 changes: 218 additions & 0 deletions src/__tests__/__snapshots__/render.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,224 @@ exports[`debug changing component: bananaFresh button message should now be "fre
</View>"
`;

exports[`debug should use debugOptions from config when no option is specified 1`] = `
"<View>
<Text>
hello
</Text>
</View>"
`;

exports[`debug should use given options over config debugOptions 1`] = `
"<View
style={
Object {
"backgroundColor": "red",
}
}
>
<Text>
hello
</Text>
</View>"
`;

exports[`debug with all props filtered 1`] = `
"<View>
<Text>
Is the banana fresh?
mdjastrzebski marked this conversation as resolved.
Show resolved Hide resolved
</Text>
<Text>
not fresh
</Text>
<TextInput />
<TextInput />
<TextInput />
<TextInput />
<View>
<Text>
Change freshness!
</Text>
</View>
<Text>
First Text
</Text>
<Text>
Second Text
</Text>
<Text>
0
</Text>
</View>"
`;

exports[`debug with only children prop 1`] = `
"<View>
<Text>
Is the banana fresh?
</Text>
<Text>
not fresh
</Text>
<TextInput />
<TextInput />
<TextInput />
<TextInput />
<View>
<Text>
Change freshness!
</Text>
</View>
<Text>
First Text
</Text>
<Text>
Second Text
</Text>
<Text>
0
</Text>
</View>"
`;

exports[`debug with only prop whose value is bananaChef 1`] = `
"<View>
<Text>
Is the banana fresh?
</Text>
<Text>
not fresh
</Text>
<TextInput />
<TextInput
testID="bananaChef"
/>
<TextInput />
<TextInput />
<View>
<Text>
Change freshness!
</Text>
</View>
<Text>
First Text
</Text>
<Text>
Second Text
</Text>
<Text>
0
</Text>
</View>"
`;

exports[`debug with only props from TextInput components 1`] = `
"<View>
<Text>
Is the banana fresh?
</Text>
<Text>
not fresh
</Text>
<TextInput
placeholder="Add custom freshness"
testID="bananaCustomFreshness"
value="Custom Freshie"
/>
<TextInput
defaultValue="What did you inspect?"
placeholder="Who inspected freshness?"
testID="bananaChef"
value="I inspected freshie"
/>
<TextInput
defaultValue="What banana?"
/>
<TextInput
defaultValue="hello"
value=""
/>
<View>
<Text>
Change freshness!
</Text>
</View>
<Text>
First Text
</Text>
<Text>
Second Text
</Text>
<Text>
0
</Text>
</View>"
`;

exports[`debug: another custom message 1`] = `
"another custom message

<View>
<Text>
Is the banana fresh?
</Text>
<Text
testID="bananaFresh"
>
not fresh
</Text>
<TextInput
placeholder="Add custom freshness"
testID="bananaCustomFreshness"
value="Custom Freshie"
/>
<TextInput
defaultValue="What did you inspect?"
placeholder="Who inspected freshness?"
testID="bananaChef"
value="I inspected freshie"
/>
<TextInput
defaultValue="What banana?"
/>
<TextInput
defaultValue="hello"
value=""
/>
<View
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function onBlur]}
onClick={[Function onClick]}
onFocus={[Function onFocus]}
onResponderGrant={[Function onResponderGrant]}
onResponderMove={[Function onResponderMove]}
onResponderRelease={[Function onResponderRelease]}
onResponderTerminate={[Function onResponderTerminate]}
onResponderTerminationRequest={[Function onResponderTerminationRequest]}
onStartShouldSetResponder={[Function onStartShouldSetResponder]}
>
<Text>
Change freshness!
</Text>
</View>
<Text
testID="duplicateText"
>
First Text
</Text>
<Text
testID="duplicateText"
>
Second Text
</Text>
<Text>
0
</Text>
</View>"
`;

exports[`debug: shallow 1`] = `
"<View>
<Text>
Expand Down
6 changes: 5 additions & 1 deletion src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ test('getConfig() returns existing configuration', () => {

test('configure() overrides existing config values', () => {
configure({ asyncUtilTimeout: 5000 });
expect(getConfig().asyncUtilTimeout).toEqual(5000);
configure({ defaultDebugOptions: { message: 'debug message' } });
expect(getConfig()).toEqual({
asyncUtilTimeout: 5000,
defaultDebugOptions: { message: 'debug message' },
});
});

test('resetToDefaults() resets config to defaults', () => {
Expand Down
Loading