How to use spectron - 10 common examples

To help you get started, we’ve selected a few spectron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nklayman / vue-cli-plugin-electron-builder / __tests__ / commands.spec.js View on Github external
test('uses custom output dir and url', async () => {
    const { url } = await runSpectron(
      {},
      {
        url: 'http://localhost:1234/',
        outputDir: 'customOutput'
      }
    )
    // Proper URL is returned
    expect(url).toBe('http://localhost:1234/')
    const appArgs = Application.mock.calls[0][0]
    // Spectron is launched with proper path to output dir
    expect(appArgs.args).toEqual(['customOutput'])
  })
github nklayman / vue-cli-plugin-electron-builder / __tests__ / commands.spec.js View on Github external
test('uses custom spectron options if provided', async () => {
    await runSpectron({ spectronOptions: { testKey: 'expected' } })
    // Custom spectron option is passed through
    expect(Application.mock.calls[0][0].testKey).toBe('expected')
  })
github IBM / kui / tests / lib / common.js View on Github external
opts.path = electron // this means spectron will use electron located in node_modules
    opts.args = [ appMain ] // in this mode, we need to specify the main.js to use
  }

  if (process.env.CHROMEDRIVER_PORT) {
    opts.port = process.env.CHROMEDRIVER_PORT
  }
  if (process.env.WSKNG_NODE_DEBUG) {
    // pass WSKNG_DEBUG on to NODE_DEBUG for the application
    opts.env.NODE_DEBUG = process.env.WSKNG_NODE_DEBUG
  }
  if (process.env.DEBUG) {
    opts.env.DEBUG = process.env.DEBUG
  }

  return new Application(opts)
}
github zeit / hyper / test / index.ts View on Github external
pathToBinary = path.join(__dirname, '../dist/linux-unpacked/hyper');
      break;

    case 'darwin':
      pathToBinary = path.join(__dirname, '../dist/mac/Hyper.app/Contents/MacOS/Hyper');
      break;

    case 'win32':
      pathToBinary = path.join(__dirname, '../dist/win-unpacked/Hyper.exe');
      break;

    default:
      throw new Error('Path to the built binary needs to be defined for this platform in test/index.js');
  }

  app = new Application({
    path: pathToBinary
  });

  await app.start();
});
github taku-o / myukkurivoice / test / helpWindow.js View on Github external
before(function () {
        var fsprefix = "_myubo_test" + Date.now().toString(36);
        var dirPath = temp.mkdirSync(fsprefix);
        this.app = new spectron_1.Application({
            path: 'MYukkuriVoice-darwin-x64/MYukkuriVoice.app/Contents/MacOS/MYukkuriVoice',
            env: { DEBUG: 1, NODE_ENV: 'test', userData: dirPath }
        });
        return this.app.start();
    });
    after(function () {
github railsware / upterm / test / e2e.ts View on Github external
before(async () => {
        app = new Application({path: "node_modules/.bin/electron", args: ["."]});
    });
github taku-o / myukkurivoice / test / specWindow-service-aques.js View on Github external
before(function () {
        var fsprefix = "_myubo_test" + Date.now().toString(36);
        dirPath = temp.mkdirSync(fsprefix);
        this.app = new spectron_1.Application({
            path: 'MYukkuriVoice-darwin-x64/MYukkuriVoice.app/Contents/MacOS/MYukkuriVoice',
            env: { DEBUG: 1, NODE_ENV: 'test', userData: dirPath }
        });
        return this.app.start();
    });
    after(function () {
github NebulousLabs / Sia-UI / test / main.js View on Github external
before('start electron', function() {
		app = new Application({
			path: Path.join(__dirname, '../node_modules/.bin/electron'),
			args: [Path.join(__dirname, '..')],
		});
		return app.start();
	});
github taku-o / myukkurivoice / test / specWindow-service-data.js View on Github external
before(function () {
        var fsprefix = "_myubo_test" + Date.now().toString(36);
        dirPath = temp.mkdirSync(fsprefix);
        this.app = new spectron_1.Application({
            path: 'MYukkuriVoice-darwin-x64/MYukkuriVoice.app/Contents/MacOS/MYukkuriVoice',
            env: { DEBUG: 1, NODE_ENV: 'test', userData: dirPath }
        });
        return this.app.start();
    });
    after(function () {
github dat-land / dat-desktop / tests / index.js View on Github external
function createApp (t) {
  var app = new spectron.Application({
    path: path.join(__dirname, '../node_modules/.bin/electron'),
    args: [
      path.join(__dirname, '../index.js'),
      '--data',
      TEST_DATA,
      '--db',
      TEST_DATA_DB
    ],
    env: {
      NODE_ENV: 'test',
      RUNNING_IN_SPECTRON: true,
      OPEN_RESULT: FIXTURES
    }
  })
  process.on('SIGTERM', () => endTest(app))
  return app

spectron

Easily test your Electron apps using ChromeDriver and WebdriverIO.

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis