electron-ava
Electron testing in AVA
Last updated 3 years ago by woutervandberg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install electron-ava 
SYNC missed versions from official npm registry.

Electron-AVA

CircleCI

All the simpleness of AVA tests for Electron.

Usage

If you are already using ava, you can just replace ava with electron-ava in your package.json (assuming all your tests run in the main process. If not, see renderer tests).

Otherwise, you can install electron-ava with the following command:

$ npm install electron-ava --save-dev

Or, if you prefer yarn:

$ yarn add electron-ava -D

Then add the following in your package.json:

"scripts": {
	"test": "electron-ava"
}

It should now look a bit like this:

{
	"scripts": {
		"test": "electron-ava"
	},
	"devDependencies": {
		"electron-ava": "^0.1.0"
	}
}

That's all! You can now run your Electron tests in AVA using yarn test or npm test.

Command line interface

  Usage
    electron-ava [<file|directory|glob> ...]

  Options
    --fail-fast             Stop after first test failure
    --serial, -s            Run tests serially
    --tap, -t               Generate TAP output
    --verbose, -v           Enable verbose output
    --no-cache              Disable the transpiler cache
    --no-power-assert       Disable Power Assert
    --match, -m             Only run tests with matching title (Can be repeated)
    --watch, -w             Re-run tests when tests and source files change
    --source, -S            Pattern to match source files so tests can be re-run (Can be repeated)
    --timeout, -T           Set global timeout
    --concurrency, -c       Maximum number of test files running at the same time (EXPERIMENTAL)
    --update-snapshots, -u  Update snapshots
    --renderer              Run the tests in the renderer process

  Examples
    electron-ava
    electron-ava test.js test2.js
    electron-ava test-*.js
    electron-ava test

  Default patterns when no arguments:
  test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js

The CLI has the same options as the AVA CLI, except for the options --init and --renderer. --init has not yet been added and --renderer has been added.

--renderer allows you to run the tests in the renderer process instead of the main process.

Renderer process tests

If you want to run your tests in the renderer process, you can add the renderer option to the electron-ava section in your package.json and give it the value true. This config works the same as the ava config.

Your package.json then should look like this:

{
	"scripts": {
		"test": "electron-ava"
	},
	"devDependencies": {
		"electron-ava": "^0.1.0"
	},
	"electron-ava": {
		"renderer": true
	}
}

Window options

If you want to pass options to the browser window for the renderer process, you can do this by adding the windowOptions option to your config. This object will then be passed to the BrowserWindow constructor.

For example, if you want to have with the title My fancy tests, you could update your package.json to look like this:

{
	"scripts": {
		"test": "electron-ava"
	},
	"devDependencies": {
		"electron-ava": "^0.1.0"
	},
	"electron-ava": {
		"renderer": true,
		"windowOptions": {
			"title": "My fancy tests"
		}
	}
}

Current Tags

  • 0.3.0                                ...           latest (3 years ago)

4 Versions

  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 4
Dependencies (12)
Dev Dependencies (1)
  • xo ^0.17.1
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |