How to use getConfigPath method in Karma

Best JavaScript code snippet using karma

index.test.js

Source:index.test.js Github

copy

Full Screen

...16 expect(obtainConfigObject).not.to.be.null;17 done();18 });19 it('should get the correct file name according to stage and name', done => {20 expect(getConfigPath('global', 'myprogram', 'production')).to.equal('/etc/myprogram/production.conf.json');21 expect(getConfigPath('global', 'myprogram', 'staging')).to.equal('/etc/myprogram/staging.conf.json');22 expect(getConfigPath('global', 'myprogram', 'development')).to.equal('/etc/myprogram/development.conf.json');23 expect(getConfigPath('global', 'myprogram', 'test')).to.equal('/etc/myprogram/test.conf.json');24 expect(getConfigPath('global', 'myprogram', 'local')).to.equal('/etc/myprogram/local.conf.json');25 done();26 });27 it('should get the correct file name according to config type and name', done => {28 expect(getConfigPath('global', 'myprogram', 'production')).to.equal('/etc/myprogram/production.conf.json');29 expect(getConfigPath('user', 'myprogram', 'production')).to.equal(path.join(process.env.HOME, '.myprogram', '/production.conf.json'));30 expect(getConfigPath('local', 'myprogram', 'production')).to.equal('production.conf.json');31 done();32 });33 it('should not accept invalid config types', done => {34 expect(getConfigPath.bind(null, 'invalidtype', 'myprogram', 'production')).to.throw('Unsupported type: invalidtype');35 done();36 });37 it('should not accept invalid stage types', done => {38 expect(getConfigPath.bind(null, 'global', 'myprogram', 'invalidstage')).to.throw('Unsupported env type! invalidstage');39 done();40 });41 it('should overwrite according to this order: global, user, local, env, arg', done => {42 const config = obtainConfigObject('./test/global.json', './test/user.json', './test/local.json');43 expect(config.get('fromGlobal')).to.equal(1);44 expect(config.get('fromUser')).to.equal(2);45 expect(config.get('fromLocal')).to.equal(3);46 done();47 });48 it('should create a config on call', done => {49 expect(senodeconf('test')).not.to.be.null;50 done();51 });52 it('should allow specifying custom environments', done => {53 expect(senodeconf.bind(null, 'test', {allowedEnv: ['foo', 'development']})).not.to.throw();54 done();55 });56 it('should allow setting a default environment that is used if NODE_ENV is not specified', done => {57 expect(senodeconf.bind(null, 'test', {allowedEnv: ['foo'], defaultEnv: 'foo'})).not.to.throw();58 done();59 });60 it('should throw an error if an illegal template string is provided', done => {61 expect(createStageConfigFileNameFromTemplate.bind(null, 'foo.json', 'test')).to.throw();62 expect(createStageConfigFileNameFromTemplate.bind(null, '%%STAGE%%%%STAGE%%.json', 'test')).to.throw();63 expect(createStageConfigFileNameFromTemplate.bind(null, '%%STAGE%%_%%STAGE%%.json', 'test')).to.throw();64 done();65 });66 it('should create a proper config file name according to the template specification', done => {67 expect(createStageConfigFileNameFromTemplate('%%STAGE%%.json', 'development')).to.equal('development.json');68 done();69 });70 it('should use the template string to get the config path', done => {71 expect(getConfigPath('global', 'myprogram', 'production', {72 configFileNameTemplate: '%%STAGE%%_WAT.json'73 })).to.equal('/etc/myprogram/production_WAT.json');74 done();75 });76 it('should use the default env separator if no other has been specified', done => {77 const opts = {78 };79 const oldNconf = _senodeconf.__get__('nconf');80 const nconfSpy = {81 argv: sinon.stub().returnsThis(),82 env: sinon.stub().returnsThis(),83 file: sinon.stub().returnsThis()84 };85 _senodeconf.__set__('nconf', nconfSpy);86 obtainConfigObject(...['global', 'user', 'local'].map(type => getConfigPath('local', 'name', 'development', opts)), opts);87 expect(nconfSpy.env.calledWith({separator: '_'})).to.be.true;88 _senodeconf.__set__('nconf', oldNconf);89 done();90 });91 it('should use the specified env separator', done => {92 const opts = {93 envSeparator: '___'94 };95 const oldNconf = _senodeconf.__get__('nconf');96 const nconfSpy = {97 argv: sinon.stub().returnsThis(),98 env: sinon.stub().returnsThis(),99 file: sinon.stub().returnsThis()100 };101 _senodeconf.__set__('nconf', nconfSpy);102 obtainConfigObject(...['global', 'user', 'local'].map(type => getConfigPath('local', 'name', 'development', opts)), opts);103 expect(nconfSpy.env.calledWith({separator: '___'})).to.be.true;104 _senodeconf.__set__('nconf', oldNconf);105 done();106 });...

Full Screen

Full Screen

vorlon.pluginsconfig.js

Source:vorlon.pluginsconfig.js Github

copy

Full Screen

...6 var PluginsConfig = (function () {7 function PluginsConfig() {8 }9 PluginsConfig.prototype.getPluginsFor = function (sessionid, callback) {10 var configurationFile = fs.readFileSync(config.VORLON.ConfigProvider.getConfigPath(), "utf8");11 var configurationString = configurationFile.toString().replace(/^\uFEFF/, '');12 var configuration = JSON.parse(configurationString);13 try {14 var sessionConfig = configuration.sessions[sessionid];15 }16 catch (e) {17 if (!sessionConfig || !sessionConfig.plugins || !sessionConfig.plugins.length) {18 sessionConfig = {19 includeSocketIO: (configuration.includeSocketIO != undefined) ? configuration.includeSocketIO : true,20 plugins: configuration.plugins21 };22 }23 }24 if (callback)25 callback(null, sessionConfig);26 };27 PluginsConfig.prototype.setPluginState = function (pluginid, callback) {28 var configurationFile = fs.readFileSync(config.VORLON.ConfigProvider.getConfigPath(), "utf8");29 var configurationString = configurationFile.toString().replace(/^\uFEFF/, '');30 var configuration = JSON.parse(configurationString);31 for (var i = 0; i < configuration.plugins.length; i++) {32 if (configuration.plugins[i].id == pluginid) {33 configuration.plugins[i].enabled = !configuration.plugins[i].enabled;34 fs.writeFileSync(config.VORLON.ConfigProvider.getConfigPath(), JSON.stringify(configuration, null, 4), "utf8");35 return callback(null);36 }37 }38 return callback('PluginID unknown');39 };40 PluginsConfig.prototype.setPluginName = function (pluginid, name, callback) {41 var configurationFile = fs.readFileSync(config.VORLON.ConfigProvider.getConfigPath(), "utf8");42 var configurationString = configurationFile.toString().replace(/^\uFEFF/, '');43 var configuration = JSON.parse(configurationString);44 if (!name) {45 return callback(true);46 }47 for (var i = 0; i < configuration.plugins.length; i++) {48 if (configuration.plugins[i].id == pluginid) {49 configuration.plugins[i].name = name;50 fs.writeFileSync(config.VORLON.ConfigProvider.getConfigPath(), JSON.stringify(configuration, null, 4), "utf8");51 return callback(null);52 }53 }54 return callback('PluginID unknown');55 };56 PluginsConfig.prototype.setPluginPanel = function (pluginid, panel, callback) {57 var configurationFile = fs.readFileSync(config.VORLON.ConfigProvider.getConfigPath(), "utf8");58 var configurationString = configurationFile.toString().replace(/^\uFEFF/, '');59 var configuration = JSON.parse(configurationString);60 var panelPosible = ['top', 'bottom'];61 if (!panel) {62 return callback('Panel must be defined');63 }64 if (panelPosible.indexOf(panel) == -1) {65 return callback('Panel wrong value');66 }67 for (var i = 0; i < configuration.plugins.length; i++) {68 if (configuration.plugins[i].id == pluginid) {69 configuration.plugins[i].panel = panel;70 fs.writeFileSync(config.VORLON.ConfigProvider.getConfigPath(), JSON.stringify(configuration, null, 4), "utf8");71 return callback(null);72 }73 }74 return callback('PluginID unknown');75 };76 PluginsConfig.prototype.setPluginsPosition = function (positions, callback) {77 var configurationFile = fs.readFileSync(config.VORLON.ConfigProvider.getConfigPath(), "utf8");78 var configurationString = configurationFile.toString().replace(/^\uFEFF/, '');79 var configuration = JSON.parse(configurationString);80 if (!positions) {81 return callback('Positions must be defined');82 }83 positions = JSON.parse(positions);84 var lookup = {};85 var plugins_reorganised = [];86 for (var i = 0; i < configuration.plugins.length; i++) {87 lookup[configuration.plugins[i].id] = configuration.plugins[i];88 }89 for (var i = 0; i < positions.length; i++) {90 plugins_reorganised.push(lookup[positions[i]]);91 }92 configuration.plugins = plugins_reorganised;93 fs.writeFileSync(config.VORLON.ConfigProvider.getConfigPath(), JSON.stringify(configuration, null, 4), "utf8");94 return callback('PluginID unknown');95 };96 return PluginsConfig;97 }());98 VORLON.PluginsConfig = PluginsConfig;...

Full Screen

Full Screen

karma.a9c61c27b4e500ac938fad831bc446560a369720.lib.init.formatters.js

Source:karma.a9c61c27b4e500ac938fad831bc446560a369720.lib.init.formatters.js Github

copy

Full Screen

...37}3839class JavaScriptFormatter {40 constructor () {41 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.js')42 this.REQUIREJS_TEMPLATE_FILE = getConfigPath('requirejs.config.tpl.js')43 }4445 generateConfigFile (answers) {46 const replacements = this.formatAnswers(answers)4748 return FileUtils49 .readFile(this.TEMPLATE_FILE_PATH)50 .replace(/%(.*)%/g, (a, key) => replacements[key])51 }5253 writeConfigFile (path, answers) {54 FileUtils.saveFile(path, this.generateConfigFile(answers))55 }5657 writeRequirejsConfigFile (path) {58 FileUtils.copyFile(this.REQUIREJS_TEMPLATE_FILE, path)59 }6061 formatAnswers (answers) {62 return {63 DATE: new Date(),64 BASE_PATH: answers.basePath,65 FRAMEWORKS: formatLine(answers.frameworks),66 FILES: formatFiles(answers.files, answers.onlyServedFiles),67 EXCLUDE: formatFiles(answers.exclude, []),68 AUTO_WATCH: answers.autoWatch ? 'true' : 'false',69 BROWSERS: formatLine(answers.browsers),70 PREPROCESSORS: formatPreprocessors(answers.preprocessors)71 }72 }73}7475class CoffeeFormatter extends JavaScriptFormatter {76 constructor () {77 super()78 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.coffee')79 this.REQUIREJS_TEMPLATE_FILE = getConfigPath('requirejs.config.tpl.coffee')80 }81}8283class LiveFormatter extends JavaScriptFormatter {84 constructor () {85 super()86 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.ls')87 }88}8990class TypeFormatter extends JavaScriptFormatter {91 constructor () {92 super()93 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.ts')94 }95}9697exports.JavaScript = JavaScriptFormatter98exports.Coffee = CoffeeFormatter99exports.Live = LiveFormatter100exports.Type = TypeFormatter101102exports.createForPath = function (path) {103 if (/\.coffee$/.test(path)) {104 return new CoffeeFormatter()105 }106107 if (/\.ls$/.test(path)) { ...

Full Screen

Full Screen

karma.095fc7e04cc7abb3f44a275a6c7a8b693a260f28.lib.init.formatters.js

Source:karma.095fc7e04cc7abb3f44a275a6c7a8b693a260f28.lib.init.formatters.js Github

copy

Full Screen

...37}3839class JavaScriptFormatter {40 constructor () {41 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.js')42 this.REQUIREJS_TEMPLATE_FILE = getConfigPath('requirejs.config.tpl.js')43 }4445 generateConfigFile (answers) {46 const replacements = this.formatAnswers(answers)4748 return FileUtils49 .readFile(this.TEMPLATE_FILE_PATH)50 .replace(/%(.*)%/g, (a, key) => replacements[key])51 }5253 writeConfigFile (path, answers) {54 FileUtils.saveFile(path, this.generateConfigFile(answers))55 }5657 writeRequirejsConfigFile (path) {58 FileUtils.copyFile(this.REQUIREJS_TEMPLATE_FILE, path)59 }6061 formatAnswers (answers) {62 return {63 DATE: new Date(),64 BASE_PATH: answers.basePath,65 FRAMEWORKS: formatLine(answers.frameworks),66 FILES: formatFiles(answers.files, answers.onlyServedFiles),67 EXCLUDE: formatFiles(answers.exclude, []),68 AUTO_WATCH: answers.autoWatch ? 'true' : 'false',69 BROWSERS: formatLine(answers.browsers),70 PREPROCESSORS: formatPreprocessors(answers.preprocessors)71 }72 }73}7475class CoffeeFormatter extends JavaScriptFormatter {76 constructor () {77 super()78 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.coffee')79 this.REQUIREJS_TEMPLATE_FILE = getConfigPath('requirejs.config.tpl.coffee')80 }81}8283class LiveFormatter extends JavaScriptFormatter {84 constructor () {85 super()86 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.ls')87 }88}8990class TypeFormatter extends JavaScriptFormatter {91 constructor () {92 super()93 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.ts')94 }95}9697exports.JavaScript = JavaScriptFormatter98exports.Coffee = CoffeeFormatter99exports.Live = LiveFormatter100exports.Type = TypeFormatter101102exports.createForPath = function (path) {103 if (/\.coffee$/.test(path)) {104 return new CoffeeFormatter()105 }106107 if (/\.ls$/.test(path)) { ...

Full Screen

Full Screen

formatters.js

Source:formatters.js Github

copy

Full Screen

...27 return path.join(__dirname, `/../../${file}`)28}29class JavaScriptFormatter {30 constructor () {31 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.js')32 this.REQUIREJS_TEMPLATE_FILE = getConfigPath('requirejs.config.tpl.js')33 }34 generateConfigFile (answers) {35 const replacements = this.formatAnswers(answers)36 return FileUtils37 .readFile(this.TEMPLATE_FILE_PATH)38 .replace(/%(.*)%/g, (a, key) => replacements[key])39 }40 writeConfigFile (path, answers) {41 FileUtils.saveFile(path, this.generateConfigFile(answers))42 }43 writeRequirejsConfigFile (path) {44 FileUtils.copyFile(this.REQUIREJS_TEMPLATE_FILE, path)45 }46 formatAnswers (answers) {47 return {48 DATE: new Date(),49 BASE_PATH: answers.basePath,50 FRAMEWORKS: formatLine(answers.frameworks),51 FILES: formatFiles(answers.files, answers.onlyServedFiles),52 EXCLUDE: formatFiles(answers.exclude, []),53 AUTO_WATCH: answers.autoWatch ? 'true' : 'false',54 BROWSERS: formatLine(answers.browsers),55 PREPROCESSORS: formatPreprocessors(answers.preprocessors)56 }57 }58}59class CoffeeFormatter extends JavaScriptFormatter {60 constructor () {61 super()62 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.coffee')63 this.REQUIREJS_TEMPLATE_FILE = getConfigPath('requirejs.config.tpl.coffee')64 }65}66class LiveFormatter extends JavaScriptFormatter {67 constructor () {68 super()69 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.ls')70 }71}72class TypeFormatter extends JavaScriptFormatter {73 constructor () {74 super()75 this.TEMPLATE_FILE_PATH = getConfigPath('config.tpl.ts')76 }77}78exports.JavaScript = JavaScriptFormatter79exports.Coffee = CoffeeFormatter80exports.Live = LiveFormatter81exports.Type = TypeFormatter82exports.createForPath = function (path) {83 if (/\.coffee$/.test(path)) {84 return new CoffeeFormatter()85 }86 if (/\.ls$/.test(path)) {87 return new LiveFormatter()88 }89 if (/\.ts$/.test(path)) {...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

1/*2 Handles config for the app, all config are stored in the user data directory3 */4const fs = require("fs");5const file = require("./file.js")6module.exports = {7 create: function (name, path, data) {8 if (!path || path.trim().length === 0) {9 path = file.get(name).path();10 name = path = file.get(name).filename();11 }12 // let stream = fs.createWriteStream(getConfigPath (name, path), ["a"]);13 if (data && typeof data === "string") {14 fs.writeFileSync(getConfigPath (name, path), data);15 } else if (data && typeof data !== "string") {16 fs.writeFileSync(getConfigPath (name, path), JSON.stringify(data, null, 4));17 }18 },19 get: function (name, path) {20 if (!path || path.trim().length === 0) {21 path = file.get(name).path();22 name = file.get(name).name();23 }24 // console.log(getConfigPath (name, path))25 // gets a config.json26 try {27 return JSON.parse(fs.readFileSync(getConfigPath (name, path)))28 } catch (e) {29 console.error(e)30 }31 },32 delete: function (name, path) {33 if (!path || path.trim().length === 0) {34 path = file.get(name).path();35 name = path = file.get(name).filename();36 }37 // deletes a config.json38 fs.unlinkSync(getConfigPath (name, path));39 },40 rename: function (name, path) {41 if (!path || path.trim().length === 0) {42 path = file.get(name).path();43 name = path = file.get(name).filename();44 }45 fs.renameSync(getConfigPath (name, path))46 }47};48function getConfigPath (name, path) {49 let filepath = path;50 // create a config.json51 if (path.trim().indexOf("/", path.trim().length - 1) === -1) {52 filepath += "/";53 }54 if (name.indexOf(".json") === -1) {55 filepath += name+".json";56 }57 return filepath;...

Full Screen

Full Screen

apiController.js

Source:apiController.js Github

copy

Full Screen

...3ISY.ApiController.BuildVersion= function(customMapConfig){4 var apiPathPrefix = 'assets/';5 var configName = customMapConfig.GetConfigName();6 function getGeoInnsynConfig(){7 return getConfigPath() + configName + '.xml';8 }9 function getLayerStatus(){10 return getConfigPath() + 'LayerStatus.json';11 }12 function getDefaultMarkerPath(){13 return apiPathPrefix + 'img/pin-md-red.png';14 }15 function getDefaultWinMapIco(){16 return apiPathPrefix + 'img/WinMap_64.png';17 }18 function getConfigPath(){19 return apiPathPrefix + 'mapConfig/';20 }21 return {22 GetGeoInnsynConfig: getGeoInnsynConfig,23 GetLayerStatus: getLayerStatus,24 GetDefaultMarkerPath: getDefaultMarkerPath,25 GetDefaultWinMapIco: getDefaultWinMapIco,26 GetConfigPath: getConfigPath27 };28};29ISY.ApiController.DistVersion = function(customMapConfig){30 var baseUrl = 'http://geoinnsyn.nois.no/';31 var apiPathPrefix = 'api/v1/';32 var defaultMapConfig = 'demo';33 var configName = customMapConfig.GetConfigName() === undefined ? defaultMapConfig : customMapConfig.GetConfigName();34 function getGeoInnsynConfig(){35 return getConfigPath() + configName;36 }37 function getLayerStatus(){38 return getConfigPath() + configName + '/status';39 }40 function getDefaultMarkerPath(){41 return baseUrl + 'assets/img/pin-md-red.png';42 }43 function getConfigList() {44 return getConfigPath() + 'list';45 }46 function getConfigPath(){47 return baseUrl + apiPathPrefix + 'mapConfig/';48 }49 return {50 GetGeoInnsynConfig: getGeoInnsynConfig,51 GetLayerStatus: getLayerStatus,52 GetDefaultMarkerPath: getDefaultMarkerPath,53 GetConfigList: getConfigList,54 GetConfigPath: getConfigPath55 };...

Full Screen

Full Screen

util.js

Source:util.js Github

copy

Full Screen

...4const merge = require("deepmerge");5module.exports = {6 // TODO: migration system that changes values if their name/location in the config were changed7 Config: class {8 constructor(configData = fs.readFileSync(module.exports.getConfigPath(), "utf-8")) {9 this.path = module.exports.getConfigPath();10 this.data = merge(require("./mcutils.config.json"), JSON.parse(configData));11 this.save();12 }13 save() {14 fs.writeFileSync(this.path, `${JSON.stringify(this.data, null, " ")}\n`);15 }16 },17 getConfigPath() {18 return path.join(process.cwd(), "mcutils.config.json");19 },20 configExists() {21 return fs.existsSync(this.getConfigPath());22 },23 getConfig() {24 if (this.configExists()) {25 return new this.Config();26 }27 warn("Config doesn't exist, creating one");28 fs.writeFileSync(this.getConfigPath(), fs.readFileSync(path.join(__dirname, "mcutils.config.json"), "utf-8"));29 return new this.Config();30 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var path = require('path');2var configPath = path.resolve(__dirname, 'karma.conf.js');3var karma = require('karma').server;4karma.start({5}, function() {6 console.log('Karma has exited with ' + exitCode);7 process.exit(exitCode);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var path = require('path');2var configPath = path.resolve(__dirname, 'karma.conf.js');3var karma = require('karma');4var config = karma.config;5var server = karma.server;6var cfg = config.parseConfig(configPath);7server.start(cfg, function(exitCode) {8 console.log('Karma has exited with ' + exitCode);9 process.exit(exitCode);10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var karmaServer = require('karma').Server;2var karmaConfig = karmaServer.getConfigPath();3console.log(karmaConfig);4module.exports = function(config) {5 config.set({6 preprocessors: {},7 })8}

Full Screen

Using AI Code Generation

copy

Full Screen

1import KarmaConfiguration from 'karma-configuration';2const karmaConfiguration = new KarmaConfiguration();3const karmaConfigPath = karmaConfiguration.getConfigPath();4import KarmaConfiguration from 'karma-configuration';5const karmaConfiguration = new KarmaConfiguration();6const karmaConfig = karmaConfiguration.getKarmaConfig();7import KarmaConfiguration from 'karma-configuration';8const karmaConfiguration = new KarmaConfiguration();9const karmaConfigPath = karmaConfiguration.getKarmaConfigPath();10import KarmaConfiguration from 'karma-configuration';11const karmaConfiguration = new KarmaConfiguration();12const karmaConfigObject = karmaConfiguration.getKarmaConfigObject();13import KarmaConfiguration from 'karma-configuration';14const karmaConfiguration = new KarmaConfiguration();15const karmaConfigFilePath = karmaConfiguration.getKarmaConfigFilePath();16import KarmaConfiguration from 'karma-configuration';17const karmaConfiguration = new KarmaConfiguration();18const karmaConfigFileContent = karmaConfiguration.getKarmaConfigFileContent();19import KarmaConfiguration from 'karma-configuration';20const karmaConfiguration = new KarmaConfiguration();21const karmaConfigFileObject = karmaConfiguration.getKarmaConfigFileObject();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Karma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful