diff --git a/.changeset/brave-cobras-hide.md b/.changeset/brave-cobras-hide.md
new file mode 100644
index 0000000000..22ba74aeac
--- /dev/null
+++ b/.changeset/brave-cobras-hide.md
@@ -0,0 +1,5 @@
+---
+"@lynx-js/testing-environment": patch
+---
+
+Fix `getJSContext` or `getCoreContext` is not a function.
diff --git a/packages/react/testing-library/src/__tests__/end-to-end.test.jsx b/packages/react/testing-library/src/__tests__/end-to-end.test.jsx
index 6b368299db..c33353b1fc 100644
--- a/packages/react/testing-library/src/__tests__/end-to-end.test.jsx
+++ b/packages/react/testing-library/src/__tests__/end-to-end.test.jsx
@@ -174,7 +174,7 @@ test('it waits for the data to be loaded', async () => {
const loading = () => {
return screen.getByText('Loading...');
};
- await waitForElementToBeRemoved(loading);
+ await waitForElementToBeRemoved(loading, { timeout: 50_000 });
expect(document.body).toMatchInlineSnapshot(`
diff --git a/packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx b/packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx
index b91174cdaa..a6a2407da7 100644
--- a/packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx
+++ b/packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx
@@ -41,7 +41,9 @@ describe('lazy bundle', () => {
`);
- await waitForElementToBeRemoved(() => screen.getByText('loading...'));
+ await waitForElementToBeRemoved(() => screen.getByText('loading...'), {
+ timeout: 50_000,
+ });
expect(container.firstChild).toMatchInlineSnapshot(`
diff --git a/packages/testing-library/testing-environment/src/index.ts b/packages/testing-library/testing-environment/src/index.ts
index 9612a26cc0..cf517719fc 100644
--- a/packages/testing-library/testing-environment/src/index.ts
+++ b/packages/testing-library/testing-environment/src/index.ts
@@ -202,6 +202,7 @@ function injectMainThreadGlobals(target?: any, polyfills?: any) {
const {
performance,
+ CoreContext,
JsContext,
__LoadLepusChunk,
} = polyfills || {};
@@ -222,6 +223,7 @@ function injectMainThreadGlobals(target?: any, polyfills?: any) {
target.globDynamicComponentEntry = '__Card__';
target.lynx = {
performance,
+ getCoreContext: (() => CoreContext),
getJSContext: (() => JsContext),
reportError: (e: Error) => {
throw e;
@@ -272,6 +274,7 @@ function injectBackgroundThreadGlobals(target?: any, polyfills?: any) {
app,
performance,
CoreContext,
+ JsContext,
__LoadLepusChunk,
} = polyfills || {};
if (typeof target === 'undefined') {
@@ -319,6 +322,7 @@ function injectBackgroundThreadGlobals(target?: any, polyfills?: any) {
};
}),
getCoreContext: (() => CoreContext),
+ getJSContext: (() => JsContext),
getJSModule: (moduleName) => {
if (moduleName === 'GlobalEventEmitter') {
return globalEventEmitter;