Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling testWithSpectron() opens infinite windows #467

Closed
thislooksfun opened this issue Sep 11, 2019 · 6 comments
Closed

Calling testWithSpectron() opens infinite windows #467

thislooksfun opened this issue Sep 11, 2019 · 6 comments

Comments

@thislooksfun
Copy link

Describe the bug
Calling testWithSpectron() hangs the tests, and starts opening as many Electron windows as it can until the tests time out.

To Reproduce
Run the following spec:

import testWithSpectron from "vue-cli-plugin-electron-builder/lib/testWithSpectron";
import chai, { expect } from "chai";
import chaiAsPromised from "chai-as-promised";

chai.use(chaiAsPromised);

describe("Application launch", function() {
  this.timeout(30000);

  beforeEach(function() {
    console.log("Before Each -- testWithSpectron()");
    return testWithSpectron().then(instance => {
      console.log("testWithSpectron().then");
      this.app = instance.app;
      this.stopServe = instance.stopServe;
    });
  });

  beforeEach(function() {
    console.log("Before Each -- chaiAsPromised");
    chaiAsPromised.transferPromiseness = this.app.transferPromiseness;
  });

  afterEach(function() {
    console.log("After");
    if (this.app && this.app.isRunning()) {
      return this.stopServe();
    }
  });

  it("opens a window", function() {
    console.log("opens?");
    const gwc = this.app.client.getWindowCount();
    console.log(gwc);
    return expect(gwc).to.eventually.have.at.least(1);
  });
});

Expected behavior
I expected the output

> Before Each -- testWithSpectron()
> testWithSpectron().then
> Before Each -- chaiAsPromised
> opens?
> After

And for it to only open one Electron window (or maybe even 0, if it should be headless).

Instead, it opens 5-10 windows (just keeps going until Mocha times out).

Screenshots
Screen Shot 2019-09-10 at 9 54 53 PM
Screen Shot 2019-09-10 at 9 55 34 PM
Screen Shot 2019-09-10 at 9 56 07 PM

Environment (please complete the following information):

  • OS and version: macOS 10.14.6 (18G87)
  • node version: v12.5.0
  • npm version: 6.9.0
  • yarn version (if used): N/A
  • vue-cli-plugin-electron-builder version : 1.4.0
  • electron version: 6.0.7
  • other vue plugins used:
    • @vue/cli-plugin-babel: 3.11.0
    • @vue/cli-plugin-eslint: 3.11.0
    • @vue/cli-plugin-unit-mocha: 3.11.0
    • @vue/cli-service: 3.11.0
    • @vue/test-utils: 1.0.0-beta.29
  • custom config for vcp-electron-builder:
// vue.config.js
const path = require("path");

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        Disciplines$: path.join(__dirname, "src/assets/earthdawn/disciplines"),
        Races$: path.join(__dirname, "src/assets/earthdawn/races"),
        Skills$: path.join(__dirname, "src/assets/earthdawn/skills"),
        Talents$: path.join(__dirname, "src/assets/earthdawn/talents"),
      },
    },
  },
  chainWebpack: config => {
    config.module
      .rule("yaml")
      .test(/\.ya?ml$/)
      .use("js-yaml-loader")
      .loader("js-yaml-loader")
      .end();
  },
  pluginOptions: {
    electronBuilder: {
      chainWebpackMainProcess: config => {
        config.resolve.alias.set("@", path.join(__dirname, "src/"));
      },
    },
  },
};

Additional context
N/A

@kelsos
Copy link

kelsos commented Oct 1, 2019

@thislooksfun any luck with that? I am also stumbling on the exact same issue.

ekoeryanto added a commit to ekoeryanto/vue-cli-plugin-electron-builder that referenced this issue Oct 10, 2019
@ekoeryanto
Copy link

If you in hurry, just like me.
try

npm i -D git://github.com/ekoeryanto/vue-cli-plugin-electron-builder#patch-1

@JBSoul
Copy link

JBSoul commented Oct 11, 2019

I had the same issue and couldn't find any solution until now. Your patch solved it nicely :)

@nklayman
Copy link
Owner

V2.0 of this plugin includes an upgrade to spectron. I will release it soon, but for now: yarn add -D vue-cli-plugin-electron-builder@alpha.

@ezpzlmnsqz1337
Copy link

For me only the @ekoeryanto patch works, the alpha version still opens infinite windows until timeout.

@nklayman
Copy link
Owner

nklayman commented Jan 9, 2020

With the v2.0.0 beta, you pass the spectron module to the testWithSpectron function, so you can install the proper version of spectron to match your electron version.

@nklayman nklayman closed this as completed Jan 9, 2020
thislooksfun added a commit to thislooksfun/earthdawn that referenced this issue Feb 8, 2020
Since nklayman/vue-cli-plugin-electron-builder#467 was fixed `testWithSpectron()` works again, but now `stopServe()` is broken.
thislooksfun added a commit to thislooksfun/earthdawn that referenced this issue Feb 8, 2020
Since nklayman/vue-cli-plugin-electron-builder#467 was fixed `testWithSpectron()` works again, but now `stopServe()` is broken.
thislooksfun added a commit to thislooksfun/earthdawn that referenced this issue Feb 8, 2020
Since nklayman/vue-cli-plugin-electron-builder#467 was fixed `testWithSpectron()` works again, but now `stopServe()` is broken.
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 a pull request may close this issue.

6 participants