Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: window is not defined With tolgee extensions #3388

Open
kowalczyk-mateusz opened this issue Oct 17, 2024 · 0 comments
Open
Assignees

Comments

@kowalczyk-mateusz
Copy link

Hi, we experience a strange issue with tolgee while testing.
We have few tests in our codebase, but sometimes we have strange error and only in Bitbucket pipelines:

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯ Uncaught Exception ⎯⎯⎯⎯⎯
ReferenceError: window is not defined
 ❯ Object.unsubscribe node_modules/@tolgee/web/src/package/tools/extension.ts:18:14
 ❯ removeEventListener node_modules/@tolgee/web/src/package/tools/extension.ts:43:18
 ❯ Timeout.expire [as _onTimeout] node_modules/@tolgee/web/src/package/tools/extension.ts:46:29
 ❯ listOnTimeout node:internal/timers:569:17
 ❯ processTimers node:internal/timers:512:7
This error originated in "src/features/component/components/__tests__/Component.test.tsx" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:
- cancel timeouts using clearTimeout and clearInterval
- wait for promises to resolve using the await keyword

When we run tests locally, everything works great, but when the tests start in the Bitbucket pipeline, it sometimes work, sometimes throw error. Don't know why, and why it throws errors. If we run tests without the tolgee inside the components, it works every time. We are using next.js 14 with app directory, and server components

Our environment:

    "react-dom": "^18.2.0",
    "react": "^18.2.0",
    "next": "^14.2.15",
    "next-intl": "^3.4.4",
    "@tolgee/format-icu": "^5.26.0",
    "@tolgee/react": "^5.26.0",
    "@artshell/tolgee-format-icu-jsx-param": "^1.0.0",
    "vitest": "^1.4.0"
    "@vitejs/plugin-react": "^4.2.1",
   "vite-plugin-env-compatible": "^2.0.1",
    "@testing-library/jest-dom": "^6.4.2",
    "@testing-library/react": "^14.2.1",
    "@testing-library/user-event": "^14.5.2",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants