Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-electron

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-electron - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

lib/karma-electron-preprocessor.js

2

CHANGELOG.md
# karma-electron changelog
3.0.0 - Moved from `framework` to `preprocessor` for better file-specific variable support (e.g. `__filename`, `__dirname`, `require`)
2.0.2 - Renamed package to `karma-electron`

@@ -3,0 +5,0 @@

14

lib/electron-launcher.js

@@ -11,3 +11,2 @@ // When we run into an uncaught exception, fail hard

var BrowserWindow = require('electron').BrowserWindow;
var url = require('url');
var program = require('commander');

@@ -17,4 +16,2 @@

program.name = 'electron-launcher';
program.option('--karma-base-path [dir]', 'Configuration used for Karma\'s base path');
program.option('--karma-url-root [dir]', 'Configuration used for Karma\'s URL root');
program.option('--user-data-dir [dir]', 'Directory to store user data');

@@ -27,4 +24,2 @@ program.option('--show', 'Boolean to make the window visible', false);

program.parse(process.argv);
assert(program.karmaBasePath, 'Expected `--karma-base-path` to be provided but it was not.');
assert(program.karmaUrlRoot, 'Expected `--karma-url-root` to be provided but it was not.');
assert(program.userDataDir, 'Expected `--user-data-dir` to be provided but it was not.');

@@ -48,10 +43,3 @@ assert(program.url, 'Expected `--url` to be provided but it was not.');

});
// Append 2 Karma-specific query parameters to our URL
// "http://localhost:9877/?id=39607501" -> `{hostname, port, query: {id: 39607501}}`
var urlObj = url.parse(program.url, true);
urlObj.query.karmaBasePath = program.karmaBasePath;
urlObj.query.karmaUrlRoot = program.karmaUrlRoot;
delete urlObj.search;
browserWindow.loadURL(url.format(urlObj), {
browserWindow.loadURL(program.url, {
// Set a custom User-Agent for better logging

@@ -58,0 +46,0 @@ // https://github.com/atom/electron/blob/v0.36.9/docs/api/browser-window.md#winloadurlurl-options

@@ -6,3 +6,3 @@ // Load in our dependencies

module.exports = xtend({},
require('./karma-electron-framework'),
require('./karma-electron-launcher'));
require('./karma-electron-launcher'),
require('./karma-electron-preprocessor'));

@@ -25,6 +25,2 @@ // Load in our dependencies

var retArr = [__dirname + '/electron-launcher.js'].concat(flags, [
// TODO: An alternative to `--karma-base-path` passing around might be via dependency injection
// See `config.client.mocha`/`mochaConfig` in https://github.com/karma-runner/karma-mocha/blob/v0.2.2/lib/index.js#L7-L17
'--karma-base-path', karmaBasePath,
'--karma-url-root', karmaUrlRoot,
'--user-data-dir', userDataDir,

@@ -31,0 +27,0 @@ '--url', url

{
"name": "karma-electron",
"description": "Karma launcher and framework for Electron",
"version": "2.0.2",
"description": "Karma launcher and preprocessor for Electron",
"version": "3.0.0",
"homepage": "https://github.com/twolfson/karma-electron",

@@ -38,3 +38,4 @@ "author": {

"commander": "~2.9.0",
"error-stack-parser": "~1.3.3"
"js-string-escape": "~1.0.0",
"minstache": "~1.2.0"
},

@@ -58,4 +59,3 @@ "devDependencies": {

"karma-launcher",
"karma-framework",
"karma-adapter",
"karma-preprocessor",
"electron"

@@ -62,0 +62,0 @@ ],

# karma-electron [![Build status](https://travis-ci.org/twolfson/karma-electron.svg?branch=master)](https://travis-ci.org/twolfson/karma-electron) [![Build status](https://ci.appveyor.com/api/projects/status/urgpvcip7kl9q2ih/branch/master?svg=true)](https://ci.appveyor.com/project/twolfson/karma-electron-launcher/branch/master)
[Karma][] launcher and framework for [Electron][]
[Karma][] launcher and preprocessor for [Electron][]

@@ -32,7 +32,6 @@ This was written to allow for directly testing in [Electron][] where we might want `require` to work automatically

// If you would like Node integration support (e.g. `require`)
// then, you must include this in `frameworks`
frameworks: [
'electron'
// Other frameworks go here (e.g. `mocha`)
]
// then, you must include this in `preprocessors`
preprocessors: {
'**/*.js': ['electron']
}
```

@@ -39,0 +38,0 @@

@@ -30,3 +30,3 @@ // Karma configuration

// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['electron', 'mocha'],
frameworks: ['mocha'],

@@ -42,2 +42,3 @@ // list of files / patterns to load in the browser

preprocessors: {
'*-test.js': ['electron']
},

@@ -44,0 +45,0 @@

// Load in our dependencies
var assert = require('assert');
// DEV: By using a `node_modules` require here, we have verified that we support external requires
void require('js-string-escape');
// DEV: By using a `./` require here, we have verified that we support relative requires

@@ -12,11 +14,7 @@ var submodule = require('./submodule');

// Example: /home/todd/github/karma-electron/test/integration-test/node-test.js
assert(/test\/integration-test\/node-test\.js$/.test(__filename),
assert(/test[\/\\]integration-test[\/\\]node-test\.js$/.test(__filename),
'Expected "' + __filename + '" to end with "test/integration-test/node-test.js"');
assert.strictEqual(/^\/base\//.test(__filename), false,
'Expected "' + __filename + '" to not start with "base"');
// Example: /home/todd/github/karma-electron/test/integration-test
assert(/test\/integration-test$/.test(__dirname),
assert(/test[\/\\]integration-test$/.test(__dirname),
'Expected "' + __dirname + '" to end with "test/integration-test"');
assert.strictEqual(/^\/base\//.test(__dirname), false,
'Expected "' + __dirname + '" to not start with "base"');
assert(process);

@@ -51,2 +49,3 @@ assert(setImmediate);

'Expected "' + submodule.filename + '" to end with "test/integration-test/submodule.js"');
// Verify `hello` property of `module.exports`
assert.strictEqual(submodule.exports.hello, 'world');

@@ -57,2 +56,11 @@ assert(/test[\/\\]integration-test[\/\\]submodule\.js$/.test(submodule.id),

assert.strictEqual(submodule.parent, module);
// Verify exported values
assert.strictEqual(submodule.hello, 'world');
// Example: /home/todd/github/karma-electron/test/integration-test/node-test.js
assert(/test[\/\\]integration-test[\/\\]submodule\.js$/.test(submodule.filename),
'Expected "' + submodule.filename + '" to end with "test/integration-test/submodule.js"');
// Example: /home/todd/github/karma-electron/test/integration-test
assert(/test[\/\\]integration-test$/.test(submodule.dirname),
'Expected "' + submodule.dirname + '" to end with "test/integration-test"');
});

@@ -59,0 +67,0 @@ });

// Export our module as our export
module.exports = module;
// Export other magic globals
module.exports.filename = __filename;
module.exports.dirname = __dirname;
// Add a special identifier for `module.exports` assertions
module.exports.hello = 'world';
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc