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.

Windows: testWithSpectron didn't kill the electron:serve process

See original GitHub issue

Describe the bug We are testing our Electron with { testWithSpectron } from 'vue-cli-plugin-electron-builder'. The stopServe and done are called, Jest says the test ends, but

Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren’t stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

I can see the serve process in the TaskManager, and it not ended:

Screenshots

image image

Environment (please complete the following information):

  • OS and version: image
  • node version: v12.13.1
  • npm version: 6.13.4
  • yarn version (if used): 1.21.1
  • vue-cli-plugin-electron-builder version : 1.4.4
  • electron version: ^5.0.0
  • other vue plugins used:
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-router": "^4.1.0",
"@vue/cli-plugin-unit-jest": "^4.1.2",
"@vue/cli-plugin-vuex": "^4.1.0",
"vue-cli-plugin-element": "^1.0.1"

Additional context Command: jest test/e2e --config='test/e2e/jest.e2e.config.js' Config:

module.exports = {
  preset: '@vue/cli-plugin-unit-jest',
  testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
};

Test:

import { testWithSpectron } from 'vue-cli-plugin-electron-builder';

jest.setTimeout(100000);

describe('Launch', () => {
  let app;
  let stopServe;
  let win;
  let client;

  beforeEach(async () => {
    // Wait for dev server to start
    ({ app, stopServe } = await testWithSpectron());
    win = app.browserWindow;
    ({ client } = app);
  });

  test('shows the proper application title', async () => {
    // Window was created
    expect(await client.getWindowCount()).toBe(1);
    // It is not minimized
    expect(win.isMinimized()).toBe(false);
    // Window is visible
    expect(win.isVisible()).toBe(true);
    // Size is correct
    const { width, height } = win.getBounds();
    expect(width).toBeGreaterThan(0);
    expect(height).toBeGreaterThan(0);
    // App is loaded properly
    expect(
      /israeli-bank-scrapers-desktop/.test(
        await client.getHTML('#app'),
      ),
    ).toBe(true);
  });

  afterEach(async (done) => {
    await stopServe();
    done();
    console.log('done');
  });
});

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nklaymancommented, Mar 5, 2021

Seems like it may be related to this: https://github.com/sindresorhus/execa/issues/96. I’m not sure what else it could be, as stopServe kills it pretty clearly. I’ll see if I can find a way to make sure it kills child processes as well.

1reaction
deankinanecommented, Jan 18, 2020

Try upgrading to the v2.0 beta. It uses a newer version of execa (used to spawn the dev server), and may fix your problem.

I’ve tried with v2.0 beta but still having the same issue however the open handle is different this time. With v1.4.4 the open handle was PIPEWRAP but now its PROCESSWRAP. Not sure if that is significant.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows: testWithSpectron didn't kill the electron:serve process -
We are testing our Electron with { testWithSpectron } from 'vue-cli-plugin-electron-builder' . The stopServe and done are called, Jest says ...
Read more >
Testing and Debugging | Vue CLI Plugin Electron Builder
First, read Electron's instructions (opens new window) for debugging the main process. Before launching Electron through your debugger, run electron:serve in ...
Read more >
electron and node on windows, kill a spawned process
If it doesn't see the main process, it can kill itself. If you don't control the spawned-app, then I'm out of ideas, but...
Read more >
electron builder not allowed to load local resource - You.com
The main.js loads fine and the application creates a window: let mainWindow = null ... so my conclusion was that the building process...
Read more >
Create an Electron application with Vue and Vuetify - ITNEXT
To stop the server you can press ctrl+c in your terminal. ... I don't use the vue ui in this article for three...
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