Skip to content

Commit

Permalink
fix(runtime): adds a testing check to the forceUpdate method (#4682)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tanner-reits committed Aug 16, 2023
1 parent 91bb7bc commit 7e9544d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/runtime/test/globals.spec.tsx
Expand Up @@ -33,10 +33,10 @@ describe('globals', () => {
});

it('build values', () => {
expect(Build.isBrowser).toBe(true);
expect(Build.isBrowser).toBe(false);
expect(Build.isDev).toBe(true);
expect(Build.isTesting).toBe(true);
expect(Build.isServer).toBe(false);
expect(Build.isServer).toBe(true);
});

it('Env is defined', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/update-component.ts
Expand Up @@ -362,7 +362,7 @@ export const postUpdateComponent = (hostRef: d.HostRef) => {
};

export const forceUpdate = (ref: any) => {
if (BUILD.updatable && Build.isBrowser) {
if (BUILD.updatable && (Build.isBrowser || Build.isTesting)) {
const hostRef = getHostRef(ref);
const isConnected = hostRef.$hostElement$.isConnected;
if (
Expand Down
4 changes: 2 additions & 2 deletions src/testing/platform/testing-build.ts
Expand Up @@ -2,7 +2,7 @@ import type * as d from '@stencil/core/internal';

export const Build: d.UserBuildConditionals = {
isDev: true,
isBrowser: true,
isServer: false,
isBrowser: false,
isServer: true,
isTesting: true,
};
2 changes: 1 addition & 1 deletion test/end-to-end/src/build-data/build-data.spec.ts
Expand Up @@ -11,7 +11,7 @@ describe('build-data', () => {
expect(root).toEqualHtml(`
<build-data>
<p>isDev: true</p>
<p>isBrowser: true</p>
<p>isBrowser: false</p>
<p>isTesting: true</p>
</build-data>
`);
Expand Down

0 comments on commit 7e9544d

Please sign in to comment.