question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--require-main does not use --compilers flag

See original GitHub issue

electron-mocha --renderer -R spec --compilers js:babel-core/register --require-main test/setup/main.js test/*.spec.js

Throws Unexpected token import.

Is there any way to enable babel compiler for main JS?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
inukshukcommented, Apr 1, 2019

The preload scripts are inserted in the renderer’s browser window using script tags before mocha runs; it’s intended mostly for people testing UMD modules or websites, not really for Electron apps. I don’t know what ts-node/register does, but if it hooks into require for instance, it would certainly not convert your preload scripts.

0reactions
pronebirdcommented, Mar 29, 2019

@inukshuk revisiting this problem once again after migrating to TypeScript. Basically here is what I do:

electron-mocha --renderer --reporter spec --require ts-node/register --require-main ts-node/register --require-main “test/setup/main.ts” --preload “test/setup/renderer.ts” “test/*.spec.ts”

But --preload script does not execute, I’ve modified the code of electron-mocha to print the options:

{ _allowUnknownOption: false,
  _versionOptionName: 'version',
  colors: true,
  reporter: 'spec',
  require: [ 'ts-node/register' ],
  ui: 'bdd',
  globals: [],
  timeouts: true,
  opts: 'test/mocha.opts',
  preload:
   [ '/Users/pronebird/app/test/setup/renderer.ts' ],
  requireMain:
   [ 'ts-node/register',
     '/Users/pronebird/app/test/setup/main.ts' ],
  rawArgs:
   [ '/Users/pronebird/app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron',
     '/Users/pronebird/app/node_modules/electron-mocha/index.js',
     '--renderer',
     '--reporter',
     'spec',
     '--require',
     'ts-node/register',
     '--require-main',
     'ts-node/register',
     '--require-main',
     'test/setup/main.ts',
     '--preload',
     'test/setup/renderer.ts',
     'test/jsonrpc-transport.spec.ts' ],
  renderer: true,
  files: [ 'test/jsonrpc-transport.spec.ts' ],
  reporterOptions: {} }

Replacing --preload with --require seem to fix this though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intel Compiler Flags : TechWeb
The Intel compilers optimization flags deliberately mimic many of those used with the GNU family of compilers. The basic optimization flags are summarized...
Read more >
Understanding what flags to pass to the compiler
I can't seem to understand what flags should be passed to make this compile, let alone why. I understand that the headers aren't...
Read more >
Use compiler flags for stack protection in GCC and Clang
Smash-stacking attacks are common, but the GCC and Clang compilers have a number of flags that can help defend against them.
Read more >
Compilers — Agda 2.6.2.2 documentation
When the flag --ghc-strict is used the GHC backend generates mostly strict code. Note that functions might not be strict in unused arguments,...
Read more >
CPP/C++ Compiler Flags and Options
1.1.1 General Compiler and Linker Flags · -nostartfiles => "Do not use the standard system startup files when linking. · -nodefaultlibs => Do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found