6 Commits
Author SHA1 Message Date
Samuel AttardandClaude 9baaed782e test: load specs as native ES modules (#54171)
* test: mechanically rewrite spec imports and __dirname for native ESM

This is the automated half of loading spec/ as native ES modules and is
not expected to pass on its own; the hand-written half follows in the
next commit. A script (included in the pull request description) made
three changes to spec/*.ts and spec/lib/*.ts, then oxfmt was re-run:

* relative import specifiers gain their real file extension
* __dirname / __filename become import.meta.dirname / .filename
* files that still call require() from module code get a
  createRequire(import.meta.url) prelude

Code inside functions that are stringified and evaluated in another
process (remotely(), itremote(), template-interpolated functions and
similar) is left as it was.

* test: load specs as native ES modules with Node's type stripping

spec/package.json declares "type": "module", so the spec runner and every
spec file now load through Node's own ESM loader and built-in TypeScript
type stripping; the require.extensions transpile hook is gone. A new
spec/fixtures/package.json keeps fixtures in a CommonJS scope.

The hand-written changes on top of the mechanical rewrite:

* spec/index.js becomes an ES module and import()s its test dependencies
  after the app is ready, then uses mocha.loadFilesAsync().
* Functions that are stringified and sent to another process now arrive
  as written rather than as CommonJS transpiler output, so the
  remote-control and utility-process fixtures define the plain names
  those bodies use (chai, expect, once, setTimeout, ...) instead of the
  old `electron_1` style shims, and a few bodies require() what they use.
* The two specs that exercise lib/ sources require() them, since lib/ is
  not in a "type": "module" scope.
* spec-helpers resolves BrowserWindow lazily so it stays loadable from a
  utility process.
* tsconfig.spec.json allows .ts extension imports; spec/tsconfig.json
  points editors at it.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 15:21:31 -07:00
Samuel AttardandClaude 2774d5761f test: keep spec sources to erasable syntax and explicit type imports (#54170)
Turn on erasableSyntaxOnly and isolatedModules for the spec typecheck so
the specs only use TypeScript syntax that a plain type stripper can
remove (no enums, parameter properties, import = require or angle
bracket casts), and lint spec/ for type-only imports so they are
written as `import type` / inline `type` specifiers.

Also hoist a handful of inline require() calls in spec bodies up to the
existing top-level imports and use named imports from ws.

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 15:21:31 -07:00
David Sanders 116168f1fe test: use node16 moduleResolution in tsconfig and clean up imports (#52030)
* test: use node16 moduleResolution in tsconfig and clean up imports

* test: ignore default and module.exports from esm
2026-06-17 10:56:58 -04:00
Jeremy Rose db7c92fd57 test: drop now-empty remote runner (#35343)
* test: drop the now-empty remote runner from CI

* move fixtures to spec-main

* remove remote runner

* fix stuff

* remove global-paths hack

* move ts-smoke to spec/

* fix test after merge

* rename spec-main to spec

* no need to ignore spec/node_modules twice

* simplify spec-runner a little

* no need to hash pj/yl twice

* undo lint change to verify-mksnapshot.py

* excessive ..

* update electron_woa_testing.yml

* don't search for test-results-remote.xml

it is never produced now
2022-08-16 15:23:13 -04:00
Milan Burda db9ab80694 chore: update to latest TypeScript (#32596) 2022-01-31 20:37:40 +09:00
Samuel Attard ca701bb9af spec: initial spike of main-process based tests 2019-03-14 12:50:06 -07:00