Skip to content

Commit 183add4

Browse files
authored
Bugfix - don't require render in every test (#6318)
## Summary Since the very beginning of testing framework we had the following bug - if a given test doesn't include any render then the tests freeze. After debugging I've found that we should have initiated `_wasRenderedNull` with the opposite value: ```diff - private _wasRenderedNull: boolean = false; + private _wasRenderedNull: boolean = true; ``` ## Test plan
1 parent 1c805ae commit 183add4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

apps/common-app/src/examples/RuntimeTests/ReJest/TestRunner/TestRunner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class TestRunner {
4949
private _currentTestCase: TestCase | null = null;
5050
private _renderHook: (component: ReactElement<Component> | null) => void = () => {};
5151
private _valueRegistry: Record<string, SharedValue> = {};
52-
private _wasRenderedNull: boolean = false;
5352
private _includesOnly: boolean = false;
5453
private _syncUIRunner: SyncUIRunner = new SyncUIRunner();
5554
private _renderLock: RenderLock = new RenderLock();
@@ -81,10 +80,11 @@ export class TestRunner {
8180
}
8281

8382
public async render(component: ReactElement<Component> | null) {
84-
if (!component && this._wasRenderedNull) {
83+
if (!component && this._renderLock.wasRenderedNull()) {
8584
return;
8685
}
87-
this._wasRenderedNull = !component;
86+
87+
this._renderLock.setRenderedNull(!component);
8888
this._renderLock.lock();
8989

9090
try {

apps/common-app/src/examples/RuntimeTests/ReJest/utils/SyncUIRunner.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export class SyncUIRunner extends WaitForUnlock {
3939
}
4040

4141
export class RenderLock extends WaitForUnlock {
42+
private _wasRenderedNull: boolean = true;
43+
4244
public lock() {
4345
this._setLock(true);
4446
}
@@ -47,6 +49,14 @@ export class RenderLock extends WaitForUnlock {
4749
this._setLock(false);
4850
}
4951

52+
public wasRenderedNull() {
53+
return this._wasRenderedNull;
54+
}
55+
56+
public setRenderedNull(wasRenderedNull: boolean) {
57+
this._wasRenderedNull = wasRenderedNull;
58+
}
59+
5060
public async waitForUnlock(maxWaitTime?: number) {
5161
await this._waitForUnlock(maxWaitTime);
5262
}

0 commit comments

Comments
 (0)