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

Fix native test timeouts caused by combining fake timers and setImmediate #37715

Merged
merged 43 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2d3b799
Upgrade to @testing-library/[email protected]
dcalhoun Jan 4, 2022
f7761f7
Clean up fake timer usage after tests
dcalhoun Jan 4, 2022
07f062d
Enable combination of modern fake timers and waitFor
dcalhoun Jan 4, 2022
7a1d441
Remove global enabling of fake timers
dcalhoun Jan 4, 2022
7ec7e40
Replace jest-jasmine2 with jest-circus
dcalhoun Jan 4, 2022
8254598
Switch testing environment from jsdom to node
dcalhoun Jan 4, 2022
e35a976
Remove setImmediate global for testing environment
dcalhoun Jan 4, 2022
637090a
Polyfill required DOM APIs for testing environment
dcalhoun Jan 5, 2022
315e5cb
Avoid import of react-dom within native file
dcalhoun Jan 5, 2022
380476f
Explicitly toggle fake timers in tests
dcalhoun Jan 5, 2022
bba6d91
Reinstate legacy Jest timers
dcalhoun Jan 5, 2022
fafa79e
Disable erroneously failing test
dcalhoun Jan 6, 2022
0b3ea9a
Reinstate jest-jasmine2 to support done callback
dcalhoun Jan 6, 2022
95df56c
Refactor native unit tests away from done callback
dcalhoun Jan 6, 2022
ad43d2a
Remove Enzyme from Editor tests
dcalhoun Jan 6, 2022
61da998
Remove Enzyme from Paragraph tests
dcalhoun Jan 6, 2022
36c4d84
Remove Enzyme from BlockMover tests
dcalhoun Jan 6, 2022
3b1acec
Remove Enzyme from BlockEdit test
dcalhoun Jan 6, 2022
a5025ef
Remove Enzyme from LinksUI test
dcalhoun Jan 6, 2022
d0c6729
Remove Enzyme from ListEdit tests
dcalhoun Jan 6, 2022
02c0189
Remove Enzyme from Platform tests
dcalhoun Jan 6, 2022
b8be92f
Remove Enzyme from BlockTypesTab tests
dcalhoun Jan 6, 2022
1c8db5f
Remove Enzyme from HTMLTextInput tests
dcalhoun Jan 6, 2022
19aa31b
Remove Enzyme from ReusableBlockTab tests
dcalhoun Jan 6, 2022
3e3f9a7
Remove Enzyme from MediaUpload tests
dcalhoun Jan 6, 2022
f9cd64e
Remove Enzyme from BlockMediaUpdateProgress tests
dcalhoun Jan 7, 2022
6a6959d
Remove Enzyme from MediaUploadProgress tests
dcalhoun Jan 7, 2022
d6064e7
Fix ReferencEerror in Inserter test
dcalhoun Jan 7, 2022
2a2616a
Fix ReferencEerror in Verse test
dcalhoun Jan 7, 2022
3690805
Fix ReferencEerror in Audio test
dcalhoun Jan 7, 2022
f3f4c2c
Fix ReferencEerror in File test
dcalhoun Jan 7, 2022
ceecec8
Fix ReferencEerror in Search test
dcalhoun Jan 7, 2022
61a6520
Fix ReferencEerror in Missing test
dcalhoun Jan 7, 2022
4879647
Upgrade to @testing-library/[email protected]
dcalhoun Jan 7, 2022
e065921
Add assertions to block type tab tests
dcalhoun Jan 10, 2022
ddaac71
Remove unnecessary abstraction
dcalhoun Jan 11, 2022
6e17911
Consistently assert media block update progress spinner removal
dcalhoun Jan 11, 2022
3d817f4
Update MediaUpload test to select 'Choose from device' option
dcalhoun Jan 11, 2022
bbe9288
Remove duplicative matchMedia global definition
dcalhoun Jan 11, 2022
e703034
Add assertions to LinkSettings tests
dcalhoun Jan 11, 2022
a0cb863
Removed shallow renderer usage in tests
dcalhoun Jan 11, 2022
0abecf0
Remove unused import
dcalhoun Jan 11, 2022
1d325ef
Remove unnecessary top-level beforeAll usage
dcalhoun Jan 11, 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
77 changes: 18 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@storybook/react": "6.4.9",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "11.2.2",
"@testing-library/react-native": "7.1.0",
"@testing-library/react-native": "9.0.0",
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
"@types/classnames": "2.3.1",
"@types/eslint": "7.28.0",
"@types/estree": "0.0.50",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
import { shallow, mount } from 'enzyme';
import { render } from 'test/helpers';
import { Text } from 'react-native';

/**
* WordPress dependencies
Expand All @@ -26,39 +27,39 @@ describe( 'Edit', () => {
} );

it( 'should return null if block type not defined', () => {
const wrapper = shallow( <Edit name="core/test-block" /> );
const screen = render( <Edit name="core/test-block" /> );

expect( wrapper.type() ).toBe( null );
expect( screen.toJSON() ).toBe( null );
} );

it( 'should use edit implementation of block', () => {
const edit = () => <div />;
const edit = () => <Text>core/test-block</Text>;
registerBlockType( 'core/test-block', {
category: 'text',
title: 'block title',
edit,
} );

const wrapper = shallow( <Edit name="core/test-block" /> );
const screen = render( <Edit name="core/test-block" /> );

expect( wrapper.exists( edit ) ).toBe( true );
expect( screen.getByText( 'core/test-block' ) ).toBeDefined();
} );

it( 'should assign context', () => {
const edit = ( { context } ) => context.value;
const edit = ( { context } ) => <Text>{ context.value }</Text>;
registerBlockType( 'core/test-block', {
category: 'text',
title: 'block title',
usesContext: [ 'value' ],
edit,
} );

const wrapper = mount(
const screen = render(
<BlockContextProvider value={ { value: 'Ok' } }>
<Edit name="core/test-block" />
</BlockContextProvider>
);

expect( wrapper.html() ).toBe( 'Ok' );
expect( screen.getByText( 'Ok' ) ).toBeDefined();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class BlockMediaUpdateProgress extends Component {
<View style={ styles.mediaUploadProgress } pointerEvents="box-none">
{ showSpinner && (
<View style={ styles.progressBar }>
<Spinner progress={ progress } />
<Spinner progress={ progress } testID="spinner" />
</View>
) }
{ renderContent( {
Expand Down
Loading