2

I'm trying to test out spectron for electron in terms of testing but as I'm going through a tutorial, I keep getting this error message whenever I run npm run test:e2e. My test file syntactically correct but im not sure why i run into an error through compilation

Specs:

  • Nodejs 6.10.3

  • Electron 1.6.1

here's the error message

here's the json file package.json

{
  "name": "your-app",
  "version": "0.1.0",
  "main": "main.js",
  "scripts": {
    "start": "C:/Users/Livs/Documents/imdc/logger/node_modules/.bin/electron .",
    "test:e2e": "C:/Users/Livs/Documents/imdc/logger/test.js"
  },
  "devDependencies": {
    "electron-chromedriver": "^1.7.1",
    "electron-prebuilt": "^1.4.13",
    "electron-rebuild": "^1.5.11",
    "chai": "^3.5.0",
    "chai-as-promised": "^5.3.0",
    "electron": "^1.3.4",
    "mocha": "^3.0.2",
    "spectron": "^3.4.0"
  }
}

Heres the testing file test.js

const Application = require('spectron').Application;
const path = require('path');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');

var electronPath = path.join(__dirname, '..', 'node_modules', '.bin',     'electron');

if (process.platform === 'win32') {
    electronPath += '.cmd';
}

var appPath = path.join(__dirname, '..');

var app = new Application({
            path: electronPath,
            args: [appPath]
        });
Livius
  • 21
  • 1

1 Answers1

0

Your npm run e2e just calls the test.js file. You'll need a test runner, mocha for instance. Then you would run mocha test.js. Or change the e2e script inside package.json to run that command.

All your file paths for the scripts inside package.json should be relative to the package root, ie logger/test.js. Regarding the npm bins you only need to type the bin name, ie electron.

To solve your problem you should change your package.json test:e2e command to mocha test.js.

(You can also change your start command to electron . since custom npm commands will always look for binaries in ./node_modules/.bin

kontrollanten
  • 2,229
  • 13
  • 28