Skip to content

add missing requirement for vinyl-map - #33

Closed
stenius wants to merge 0 commit into
RocketChat:masterfrom
stenius:master
Closed

stenius wants to merge 0 commit into
RocketChat:masterfrom
stenius:master

Conversation

@stenius

@stenius stenius commented Aug 29, 2015

Copy link
Copy Markdown
Contributor

I was getting an error about vinyl-map being a missing dependency when trying to run this for the first time.

@geekgonecrazy

Copy link
Copy Markdown
Contributor

Mind moving that dependency up into the devDependencies?

@stenius stenius closed this Aug 29, 2015
jeanfbrito added a commit that referenced this pull request Jul 7, 2026
Definitively root-caused the CI check job's EvalError, replacing the
"documented as a known blocker" note from the previous commit.

@kayahr/jest-electron-runner's ElectronEnvironment monkey-patches
vm.Script#runInContext to redirect to script.runInThisContext() against
Electron's native renderer V8 context, instead of a real vm.createContext()
sandbox. Every module Jest loads (test files and all required source) is
compiled as a vm.Script and executed this way. That native context enforces
V8's AllowCodeGenerationFromStrings restriction at context-creation time -
a native embedder API, not exposed via webPreferences (contextIsolation,
nodeIntegration, sandbox: all verified empirically to have no effect), CSP
(the runner's own bootstrap HTML already sets 'unsafe-eval'), or any
documented Electron/Node command-line switch. Istanbul's coverage
instrumentation injects new Function(...) counter calls into every
instrumented module, which trips this restriction; without --coverage,
modules execute as plain compiled scripts and never hit it.

Confirmed empirically, ruling out every configurable lever before
concluding this is structural:
- contextIsolation/nodeIntegration: already least-restrictive
- sandbox: false patched directly into the runner's compiled JS, no change
- CSP: runner's own index.html already permits unsafe-eval
- coveragePathIgnorePatterns / istanbul-ignore-file / per-project
  collectCoverageFrom override - none prevent transform-time instrumentation,
  since --coverage instruments before any report-scoping filter applies
- coverageProvider v8 - fails differently (inspector session can't
  connect in this same restricted context)

@kayahr/jest-electron-runner is archived upstream (maintainer moved to
Vitest per its issue #33) - no fix will land there.

Fix: exclude the 17 affected preload/renderer-context specs from the
coverage-enabled project via testPathIgnorePatterns, gated on --coverage
being present in argv. They still run and gate CI on pass/fail under
plain yarn test - only the coverage-instrumented run skips them.

Verified: yarn test:coverage now passes 125/125 suites (was 17 failed).
yarn test unaffected, still 142/142 suites pass.
jeanfbrito added a commit that referenced this pull request Jul 9, 2026
* test: add preload and module coverage specs

* test: fix jest testMatch gaps, TDZ hoisting bugs, and test isolation

- Extend jest.config.js testMatch to cover top-level src/*.spec.ts files
  (whenReady, systemCertificates, constants) that were previously invisible
  to the test runner
- Move ui/selectors.spec.ts into ui/__tests__/ for the same reason
- Delete duplicate screenSharing/screenRecordingPermission.spec.ts (dead
  flat copy of the already-covered nested test)
- Move jitsi/main.spec.ts, screenSharing/main.spec.ts, i18n/main.spec.ts
  out of __tests__/ to the flat <module>/main.spec.ts convention; the
  __tests__/main.spec.ts path double-matched both jest projects
  (renderer + main), causing the same suite to run twice concurrently
- Fix TDZ ReferenceErrors in jitsi/main.spec.ts, screenSharing/main.spec.ts,
  i18n/main.spec.ts, browser/ipc.spec.ts, jitsi/preload.spec.ts, and
  servers/preload/window.spec.ts: ts-jest's hoist transformer moves every
  jest.mock() above all other statements unconditionally, so factories
  closing over an outer const always throw. Declare mocks inline in the
  factory and retrieve references via jest.requireMock/jest.mocked instead
- Fix jitsi/ipc.spec.ts test isolation: the module under test held
  module-level state that leaked across tests because it was statically
  imported and jest.resetModules() was a no-op against it; switch to
  await import() per test
- Tighten two weak toBeDefined() assertions in stateGroups.spec.ts to
  assert the actual default reducer state shape

* test: address CodeRabbit review feedback on PR #3393

- Fix process.platform/process.mas leaking across test files in the same
  Jest worker: PersistableValues.spec.ts, internalVideoChatWindow.spec.ts,
  dialogs.spec.ts, popupMenu.spec.ts, featureFlags.spec.ts now save and
  restore the original value instead of hardcoding or never resetting it
- Fix a real TDZ hoisting bug in dev.spec.ts (same class as the previous
  commit's fixes): jest.mock('chokidar', ...) closed over outer consts
  that get hoisted below it; declare mocks inline and retrieve via
  jest.requireMock instead
- Fix icons.spec.ts: getAppIconPath builds its path with a template
  literal (always forward slashes), but the test compared against
  path.join(...), which normalizes to backslashes on Windows CI
- Remove duplicate test coverage in utils.spec.ts: the version/userLoggedIn
  dispatch assertions were already covered verbatim by version.spec.ts and
  userLoggedIn.spec.ts

Rejected: navigation/main.spec.ts's askForCertificateTrust assertion —
CodeRabbit flagged the expected 'undefined' detail as wrong given the
source reassigns detail via t(...), but i18next is never initialized in
this spec, so t() genuinely returns undefined at runtime; verified by
running i18next.t() directly against an uninitialized instance.

* test: fix platform-dependent assertions found by CI

- acceleratorDisplay.spec.ts: the meta+option+p case relied on the CI
  runner's real process.platform for the meta->Cmd mapping (only defined
  for darwin); pass { platform: 'darwin' } explicitly like the sibling
  assertions in the same file
- navigation/main.spec.ts, systemCertificates.spec.ts: both asserted
  readFileSync/readFile was called with a hardcoded POSIX path string,
  but the real implementation builds the path via path.join(...), which
  normalizes to backslashes on Windows; wrap the expected value in
  path.join(...) too so both sides use the same OS-aware separator

Confirmed all 3 previously failed only on ubuntu-latest/windows-latest
in CI (#3393),
not locally on macOS.

* test: exclude coverage-incompatible preload specs from test:coverage

Definitively root-caused the CI check job's EvalError, replacing the
"documented as a known blocker" note from the previous commit.

@kayahr/jest-electron-runner's ElectronEnvironment monkey-patches
vm.Script#runInContext to redirect to script.runInThisContext() against
Electron's native renderer V8 context, instead of a real vm.createContext()
sandbox. Every module Jest loads (test files and all required source) is
compiled as a vm.Script and executed this way. That native context enforces
V8's AllowCodeGenerationFromStrings restriction at context-creation time -
a native embedder API, not exposed via webPreferences (contextIsolation,
nodeIntegration, sandbox: all verified empirically to have no effect), CSP
(the runner's own bootstrap HTML already sets 'unsafe-eval'), or any
documented Electron/Node command-line switch. Istanbul's coverage
instrumentation injects new Function(...) counter calls into every
instrumented module, which trips this restriction; without --coverage,
modules execute as plain compiled scripts and never hit it.

Confirmed empirically, ruling out every configurable lever before
concluding this is structural:
- contextIsolation/nodeIntegration: already least-restrictive
- sandbox: false patched directly into the runner's compiled JS, no change
- CSP: runner's own index.html already permits unsafe-eval
- coveragePathIgnorePatterns / istanbul-ignore-file / per-project
  collectCoverageFrom override - none prevent transform-time instrumentation,
  since --coverage instruments before any report-scoping filter applies
- coverageProvider v8 - fails differently (inspector session can't
  connect in this same restricted context)

@kayahr/jest-electron-runner is archived upstream (maintainer moved to
Vitest per its issue #33) - no fix will land there.

Fix: exclude the 17 affected preload/renderer-context specs from the
coverage-enabled project via testPathIgnorePatterns, gated on --coverage
being present in argv. They still run and gate CI on pass/fail under
plain yarn test - only the coverage-instrumented run skips them.

Verified: yarn test:coverage now passes 125/125 suites (was 17 failed).
yarn test unaffected, still 142/142 suites pass.

* test: fix remaining platform assumption in acceleratorDisplay.spec.ts

Line 23 (uses mac overrides by default when platform is darwin) called
formatAcceleratorForDisplay('commandorcontrol+q') with no explicit platform
option, same class of bug as the meta+option+p case fixed earlier in this
file — relies on the CI runner's real process.platform instead of testing
the darwin default explicitly. Passed on macOS CI by accident of
environment, failed on ubuntu-latest/windows-latest (real process.platform
there is linux/win32, so commandorcontrol resolved to Ctrl not Cmd).

Mocked process.platform to darwin for this specific assertion, restoring
the original value after, matching the platform-leak-safe pattern used
elsewhere in this branch.
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

Successfully merging this pull request may close these issues.

2 participants