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

Add retries to flaky multiroot semaphores tests. #559

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
12 changes: 8 additions & 4 deletions tests/useMultiRootEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ describe( 'useMultiRootEditor', () => {

describe( 'semaphores', () => {
const testSemaphoreForWatchdog = enableWatchdog => {
it( 'should assign properly `data` property to editor even if it is still mounting', async () => {
it( 'should assign properly `data` property to editor even if it is still mounting', { retry: 3 }, async () => {
Mati365 marked this conversation as resolved.
Show resolved Hide resolved
const deferInitialization = createDefer();

class SlowEditor extends TestMultiRootEditor {
Expand Down Expand Up @@ -931,16 +931,20 @@ describe( 'useMultiRootEditor', () => {
editor: SlowEditor
} ) );

await timeout( 100 );
await timeout( 500 );

// Depending on the execution order on the event loop this `setData` might be delayed by the React engine.
Mati365 marked this conversation as resolved.
Show resolved Hide resolved
// It happens only if event loop is busy and React has to wait for the next tick a little bit longer than usual.
Mati365 marked this conversation as resolved.
Show resolved Hide resolved
// It does not play well with `waitFor` below so we added few retries to make it more stable.
Mati365 marked this conversation as resolved.
Show resolved Hide resolved
// It should not be a problem in real life, as it is a rare case and might be solved in future React versions.
result.current.setData( {
intro: 'Hello World!',
content: ''
} );

await timeout( 200 );
await timeout( 500 );
Mati365 marked this conversation as resolved.
Show resolved Hide resolved

deferInitialization.resolve();
await deferInitialization.resolve();

await waitFor( () => {
expect( result.current.editor ).to.be.instanceof( SlowEditor );
Expand Down
4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export default defineConfig( {
include: [
'tests/**/*.test.[j|t]sx'
],
sequence: {
shuffle: true
},
coverage: {
provider: 'istanbul',
include: [ 'src/*' ],
Expand All @@ -63,6 +66,7 @@ export default defineConfig( {
},
reporter: [
'text-summary',
'text',
'html',
'lcovonly',
'json'
Expand Down