Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
gemini-core
Advanced tools
Utility which contains common modules for gemini and hermione.
Table of Contents
Creates mapping of test files with browsers in which they should be run and vice versa.
Example of usage:
const SetsBuilder = require('gemini-core').SetsBuilder;
const sets = {
desktop: {
files: ['desktop/tests/**.js'],
browsers: ['bro1']
},
touch-phone: {
files: ['touch-phone/tests'],
browsers: ['bro2']
}
};
SetsBuilder
.create(sets, {defaultDir: 'default/path'}) // creates setsBuilder using specified tests and options
.useSets(['desktop']) // use only the specified sets
.useBrowsers(['bro1']) // use only specified browsers
.useFiles(['desktop/tests/test.js']) // use only specified files if sets
//and files to use are not specified
.build('/root', globOpts) // builds a collection of sets with paths expanded according
// to the project root and glob options
.then((setCollection) => {
setCollection.groupByFile(); // groups all browsers of test-sets by file:
// {'desktop/tests/test.js': ['bro1']}
setCollection.groupByBrowser(); // groups all files of test-sets by browser:
// {'bro': ['desktop/tests/test.js']}
})
.done();
Returns an object with some options.
const options = require('gemini-core').config.options;
const sets = options.sets; // returns a section for configparser with two options – files and browsers.
// Default value is an empty set - all: {files: []}
Example:
const BrowserPool = require('gemini-core').BrowserPool;
// Some browser realization
class Browser {
constructor(id) {
this.id = 'bro'; // required field
this.sessionId = null; // required field
}
launch() {
return doLaunch()
.then((sessionId) => this.sessionId = sessionId);
}
// required method
reset() {
return doSomeReset();
}
quit() {
return doQuit();
}
}
const BrowserManager = {
create: (id) => new Browser(id),
start: (browser) => browser.launch(),
onStart: (browser) => emitter.emitAndWait('sessionStart', browser),
onQuit: (browser) => emitter.emitAndWait('sessionEnd', browser),
quit: (browser) => browser.quit()
};
const config = {
forBrowser: (id) => {
return {
parallelLimit: 1, // maximum number of specific browser sessions executed in parallel
sessionUseLimit: 2 // maxiumu number of session reuse (test per session, for example)
};
},
getBrowserIds: () => config.getBrowserIds(),
system: {
parallelLimit: 10 // maximum number of browser sessions at all
}
};
const pool = BrowserPool.create(BrowserManager, {
logNamespace: 'gemini', // prefix for logger. log = require('debug')(`${logNamespace}:pool:...`)
config
});
return pool.getBrowser('bro')
.then((bro) => {
...
return pool.freeBrowser(bro);
});
Example:
const BrowserAgent = require('gemini-core').BrowserAgent;
const BrowserPool = require('gemini-core').BrowserPool;
const pool = BrowserPool.create(/*BrowserManager, config*/);
const browserAgent = BrowserAgent.create('bro-id', pool);
return browserAgent.getBrowser()
.then((bro) => {
...
return browserAgent.freeBrowser(bro/*, {force: true}*/);
});
This error will be thrown on browser pool cancel:
const BrowserPool = require('gemini-core').BrowserPool;
const CancelledError = require('gemini-core').errors.CancelledError;
...
pool.getBrowser('bro')
.then((bro) => ...)
.catch((e) => {
if (e instanceof CancelledError) {
console.log('cancelled')
}
});
pool.cancel();
FAQs
Utility which contains common modules for gemini and hermione
We found that gemini-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.