Windows: testWithSpectron didn't kill the electron:serve process
See original GitHub issueDescribe 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
Environment (please complete the following information):
- OS and version:
- 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"
- custom config for vcp-electron-builder:
- (if possible) link to your repo: https://github.com/baruchiro/israeli-bank-scrapers-desktop/tree/UpdateVersions (Note to the branch)
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:
- Created 4 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.