electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 229 forks source link

Failed to run spectron with node-tap #155

Open jwu opened 7 years ago

jwu commented 7 years ago

Hi,

I try to run spectron with node-tap but failed with strange behavior. it will output the whole spectron object and will never run the test code.

Here is my test code:

const path = require('path');
const electron = require('electron');
const {Application} = require('spectron');
const tap = require('tap');

tap.test('electron', {autoend: false, timeout: 0}, t => {
  let app = null;

  t.beforeEach(() => {
    app = new Application({
      path: electron,
      args: [path.join(__dirname, 'fixtures', 'app')]
    });
    return app.start();
  });

  t.afterEach(() => {
    if (app && app.isRunning()) {
      return app.stop();
    }
  });

  t.test('should be ok in main process', () => {
    t.equal('foo', 'foo');
    t.end();
  });
});

Here is my test fixtures:

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Electron App</title>
  </head>

  <body>
    <div>Testing...</div>
  </body>
</html>

main.js

const {app, BrowserWindow} = require('electron');

global.platform = platform;
let mainWindow = null;

app.on('ready', function () {
  mainWindow = new BrowserWindow({
    center: true,
    width: 800,
    height: 600
  });
  mainWindow.loadURL('file://' + __dirname + '/index.html');
  mainWindow.on('closed', () => {
    mainWindow = null;
  });
});

package.json

{
  "name": "app",
  "version": "1.0.0",
  "main": "main.js"
}
ungoldman commented 7 years ago

Same problem here. @jwu were you able to resolve this?

jwu commented 7 years ago

still not working here. I've try several way but still failed.