Skip to content

Commit 7a9c220

Browse files
authored
Decrease timeouts in test utils (#7102)
* Decrease chance of hitting timeouts on table tests * move throw outside of act * fix TS
1 parent f459c18 commit 7a9c220

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

packages/@react-aria/test-utils/src/table.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ export class TableTester {
6868
await pressElement(this.user, cell, interactionType);
6969
}
7070
}
71-
72-
// Handle cases where the table may transition in response to the row selection/deselection
73-
await act(async () => {
74-
if (this._advanceTimer == null) {
75-
throw new Error('No advanceTimers provided for table transition.');
76-
}
77-
78-
await this._advanceTimer(200);
79-
});
8071
};
8172

8273
toggleSort = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {
@@ -145,12 +136,12 @@ export class TableTester {
145136
}
146137

147138
// Handle cases where the table may transition in response to the row selection/deselection
148-
await act(async () => {
149-
if (this._advanceTimer == null) {
150-
throw new Error('No advanceTimers provided for table transition.');
151-
}
139+
if (!this._advanceTimer) {
140+
throw new Error('No advanceTimers provided for table transition.');
141+
}
152142

153-
await this._advanceTimer(200);
143+
await act(async () => {
144+
await this._advanceTimer?.(200);
154145
});
155146

156147
await waitFor(() => {

packages/@react-spectrum/table/test/TestTableUtils.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {theme} from '@react-spectrum/theme-default';
1818
import {User} from '@react-aria/test-utils';
1919

2020
let manyItems = [];
21-
for (let i = 1; i <= 100; i++) {
21+
for (let i = 1; i <= 10; i++) {
2222
manyItems.push({id: i, foo: 'Foo ' + i, bar: 'Bar ' + i, baz: 'Baz ' + i});
2323
}
2424

0 commit comments

Comments
 (0)