Skip to content

Commit 7e9544d

Browse files
authored
fix(runtime): adds a testing check to the forceUpdate method (#4682)
This commit adds a check for `isTesting` in addition to `isBrowser` so that the forceUpdate logic can run in test environments without needing to change the testing build conditional values. These changes were causing tests to fail in Framework.
1 parent 91bb7bc commit 7e9544d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/runtime/test/globals.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ describe('globals', () => {
3333
});
3434

3535
it('build values', () => {
36-
expect(Build.isBrowser).toBe(true);
36+
expect(Build.isBrowser).toBe(false);
3737
expect(Build.isDev).toBe(true);
3838
expect(Build.isTesting).toBe(true);
39-
expect(Build.isServer).toBe(false);
39+
expect(Build.isServer).toBe(true);
4040
});
4141

4242
it('Env is defined', () => {

src/runtime/update-component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export const postUpdateComponent = (hostRef: d.HostRef) => {
362362
};
363363

364364
export const forceUpdate = (ref: any) => {
365-
if (BUILD.updatable && Build.isBrowser) {
365+
if (BUILD.updatable && (Build.isBrowser || Build.isTesting)) {
366366
const hostRef = getHostRef(ref);
367367
const isConnected = hostRef.$hostElement$.isConnected;
368368
if (

src/testing/platform/testing-build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type * as d from '@stencil/core/internal';
22

33
export const Build: d.UserBuildConditionals = {
44
isDev: true,
5-
isBrowser: true,
6-
isServer: false,
5+
isBrowser: false,
6+
isServer: true,
77
isTesting: true,
88
};

test/end-to-end/src/build-data/build-data.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('build-data', () => {
1111
expect(root).toEqualHtml(`
1212
<build-data>
1313
<p>isDev: true</p>
14-
<p>isBrowser: true</p>
14+
<p>isBrowser: false</p>
1515
<p>isTesting: true</p>
1616
</build-data>
1717
`);

0 commit comments

Comments
 (0)