How to use loadConfigFile method in ava

Best JavaScript code snippet using ava

config-helpers.js

Source:config-helpers.js Github

copy

Full Screen

...46 });47 });48 describe('loadConfigFile', function () {49 it('should return config file content', function(){50 var config = configHelpers.loadConfigFile();51 assert(config.devices !== null);52 });53 });54 describe('saveConfig', function () {55 it('it should save current config to disk', function(){56 var config = configHelpers.loadConfigFile();57 config.dumbKey = true;58 configHelpers.saveConfig();59 config = configHelpers.loadConfigFile();60 (true).should.eql(config.dumbKey,61 'Config was not properly updated.');62 });63 });64 describe('addApp', function(){65 it('should add app manifest to the config file', function () {66 var manifest = {67 'name': 'cozy-test',68 'displayName': 'Cozy Test',69 'version': '1.1.13',70 'description': 'Test app.',71 'type': 'classic'72 };73 var app = 'cozy-labs/cozy-test';74 configHelpers.addApp(app, manifest);75 var config = configHelpers.loadConfigFile();76 manifest.name.should.eql(config.apps[app].name);77 manifest.displayName.should.eql(config.apps[app].displayName);78 manifest.version.should.eql(config.apps[app].version);79 manifest.description.should.eql(config.apps[app].description);80 manifest.type.should.eql(config.apps[app].type);81 });82 });83 describe('exportApps', function(){84 it('return apps object from config file', function () {85 var manifest = {86 'name': 'cozy-test',87 'displayName': 'Cozy Test',88 'version': '1.1.13'89 };90 var app = 'cozy-labs/cozy-test';91 var appsConfig = configHelpers.exportApps();92 manifest.name.should.eql(appsConfig[app].name);93 manifest.displayName.should.eql(appsConfig[app].displayName);94 manifest.version.should.eql(appsConfig[app].version);95 });96 });97 describe('removeApp', function () {98 it('should remove app manifest from the config file', function () {99 var app = 'cozy-labs/cozy-test';100 assert(configHelpers.removeApp(app), 'did not remove app correctly.');101 var config = configHelpers.loadConfigFile();102 assert.equal(undefined, config.apps[app]);103 });104 });105 describe('addPlugin', function () {106 it('should add plugin manifest to the config file', function () {107 var manifest = {108 'name': 'cozy-test-plugin',109 'displayName': 'Cozy Test Plugin',110 'version': '1.1.13',111 'description': 'Test plugin.'112 };113 var plugin = 'cozy-labs/cozy-test-plugin';114 var config = configHelpers.loadConfigFile();115 configHelpers.addPlugin(plugin, manifest);116 manifest.name.should.eql(config.plugins[plugin].name);117 manifest.displayName.should.eql(config.plugins[plugin].displayName);118 manifest.version.should.eql(config.plugins[plugin].version);119 manifest.description.should.eql(config.plugins[plugin].description);120 });121 });122 describe('exportPlugins', function () {123 it('return plugins object from config file', function () {124 var manifest = {125 'name': 'cozy-test-plugin',126 'displayName': 'Cozy Test Plugin',127 'version': '1.1.13'128 };129 var plugin = 'cozy-labs/cozy-test-plugin';130 var pluginsConfig = configHelpers.exportPlugins();131 manifest.name.should.eql(pluginsConfig[plugin].name);132 manifest.displayName.should.eql(pluginsConfig[plugin].displayName);133 manifest.version.should.eql(pluginsConfig[plugin].version);134 });135 });136 describe('removePlugin', function () {137 it('should remove plugin manifest from the config file', function () {138 var plugin = 'cozy-labs/cozy-test-plugin';139 assert(configHelpers.removePlugin(plugin),140 'did not remove plugin correctly.');141 var config = configHelpers.loadConfigFile();142 assert.equal(undefined, config.plugins[plugin]);143 });144 });145 describe('copyDependency', function(){146 it('should copy dependency in the cozy light folder.', function () {147 var destPath = configHelpers.modulePath('path-extra');148 configHelpers.copyDependency('path-extra');149 fs.existsSync(destPath).should.eql(true,150 'did not copy the dependency.');151 });152 });153 describe('getHost', function () {154 it('returns localhost', function () {155 configHelpers.getMainAppHost().should.eql('localhost',...

Full Screen

Full Screen

ConfigFileUtil.js

Source:ConfigFileUtil.js Github

copy

Full Screen

...85}86function saveConfigFile(path, config) {87 fs.writeFileSync(path, JSON.stringify(config, null, ' '), 'utf8');88}89function loadConfigFile(path) {90 checkFileExists(path);91 try {92 return JSON.parse(fs.readFileSync(path, 'utf8'));93 } catch (err) {94 throw new Error(messageUtil.getMessage('Config file is invalid.\nFile: {0}', [path]));95 }96}97function checkFileExists(path) {98 path = path || '';99 if (!fs.existsSync(path)) {100 throw new Error(messageUtil.getMessage('Config file is not exist.\nFile: {0}', [path]));101 }102}103ConfigFileUtil.init = function (registryDirPath, configDirPath) {104 var registryFilePath = path.join(registryDirPath, '/registry.json');105 registry[appConfigFileName] = path.join(configDirPath, '/' + appConfigFileName + '.json');106 registry[propertiesConfigFileName] = path.join(configDirPath, '/' + propertiesConfigFileName + '.json');107 initConfig.registry = registry;108 if (!fs.existsSync(registryFilePath)) {109 fs.writeFileSync(registryFilePath, JSON.stringify(registry, null, ' '), 'utf8');110 }111 for (var key in initConfig.registry) {112 if (!initConfig.registry.hasOwnProperty(key)) {113 continue;114 }115 if (!fs.existsSync(initConfig.registry[key])) {116 fs.writeFileSync(initConfig.registry[key], JSON.stringify(initConfig[key], null, ' '), 'utf8');117 }118 }119 registry = loadConfigFile(registryFilePath);120};121ConfigFileUtil.isDevelop = function () {122 return loadConfigFile(registry.appConfig).isDevelop;123};124ConfigFileUtil.getJobStreamerInfo = function () {125 return loadConfigFile(registry.appConfig).jobStreamer;126};127ConfigFileUtil.getLocale = function () {128 return loadConfigFile(registry.appConfig).locale;129};130ConfigFileUtil.getXmlAttr = function () {131 return loadConfigFile(registry.appConfig).xmlAttr;132};133ConfigFileUtil.getProperties = function () {134 return loadConfigFile(registry.propertiesConfig);135};136ConfigFileUtil.setProperties = function (config) {137 saveConfigFile(registry.propertiesConfig, config);138};...

Full Screen

Full Screen

builder.mjs

Source:builder.mjs Github

copy

Full Screen

...5import { createRequire } from 'module'6import { createHash } from 'crypto'7// https://github.com/rollup/rollup/issues/42538// import loadConfigFile from 'rollup/dist/loadConfigFile.js'9function loadConfigFile(...args) {10 // https://github.com/rollup/rollup/issues/425311 const privateRequire = createRequire(require.resolve('rollup'))12 return privateRequire('./loadConfigFile.js')(...args)13}14const require = createRequire(import.meta.url)15let polyfillVersion = '__'16{17 const lockfilePath = fileURLToPath(new URL('../../pnpm-lock.yaml', import.meta.url))18 const lockfile = await readFile(lockfilePath)19 const hash = createHash('sha256')20 hash.update(lockfile)21 polyfillVersion = 'v5' + hash.digest('hex')22}23const versionFilePath = fileURLToPath(new URL('./dist/version.txt', import.meta.url))24if ((await readFile(versionFilePath, 'utf-8').catch(() => '')) === polyfillVersion) process.exit(0)25await builder({26 modules: ['es', 'web'],27 targets: [28 'iOS >= 14.0',29 // Android30 'Firefox >= 99',31 'last 2 Chrome versions',32 'last 2 Firefox versions',33 ],34 summary: {35 comment: { size: false, modules: true },36 },37 filename: fileURLToPath(new URL('./dist/ecmascript.js', import.meta.url)),38 blacklist: undefined,39})40process.chdir(fileURLToPath(new URL('./dist/', import.meta.url)))41const { options, warnings } = await loadConfigFile(fileURLToPath(new URL('./rollup.config.js', import.meta.url)), {42 format: 'es',43})44warnings.flush()45for (const optionsObj of options) {46 const bundle = await rollup(optionsObj)47 await Promise.all(optionsObj.output.map(bundle.write))48}49{50 const polyfill = fileURLToPath(new URL('./dist/ecmascript.js', import.meta.url))51 const ecmascript = await readFile(polyfill, 'utf-8')52 const regenerator = await readFile(fileURLToPath(new URL('./dist/regenerator.js', import.meta.url)), 'utf-8')53 await writeFile(polyfill, `${ecmascript};${regenerator};`)54}55await normalize(new URL('./dist/dom.js', import.meta.url))...

Full Screen

Full Screen

config-file.spec.js

Source:config-file.spec.js Github

copy

Full Screen

...22 afterEach(() => {23 fs.removeSync(".tmp");24 });25 it("filename", (done) => {26 const data = loadConfigFile(".tmp/file.json");27 expect(data).to.eql({28 key: "value"29 });30 done();31 });32 it("loads first existing file in array", (done) => {33 const data = loadConfigFile(["another.json", ".tmp/file.json"]);34 expect(data).to.eql({35 key: "value"36 });37 done();38 });39 it("empty object for when no file", (done) => {40 const data = loadConfigFile(".tmp/nope.json");41 expect(data).to.eql({});42 done();43 });44 it("loads object as config", (done) => {45 const config = loadConfigFile({46 my: "data"47 });48 expect(config).to.eql({49 my: "data"50 });51 done();52 });53 describe("extends the file config with the object passed", () => {54 it("superstatic.json", (done) => {55 fs.outputFileSync(56 "superstatic.json",57 '{"firebase": "superstatic", "public": "./"}',58 "utf-8"59 );60 const config = loadConfigFile({61 override: "test",62 public: "app"63 });64 expect(config).to.eql({65 firebase: "superstatic",66 override: "test",67 public: "app"68 });69 fs.removeSync("superstatic.json");70 done();71 });72 it("firebase.json", (done) => {73 fs.outputFileSync(74 "firebase.json",75 '{"firebase": "example", "public": "./"}',76 "utf-8"77 );78 const config = loadConfigFile({79 override: "test",80 public: "app"81 });82 expect(config).to.eql({83 firebase: "example",84 override: "test",85 public: "app"86 });87 fs.removeSync("firebase.json");88 done();89 });90 });...

Full Screen

Full Screen

resolveConfig.js

Source:resolveConfig.js Github

copy

Full Screen

...7 }8}9let config10if (env === 'staging') {11 config = loadConfigFile('./staging.js')12} else if (env === 'production') {13 config = loadConfigFile('./production.js')14} else if (env === 'production2') {15 config = loadConfigFile('./production2.js')16} else if (env === 'sandbox') {17 config = loadConfigFile('./sandbox.js')18} else if (env === 'benchmark') {19 config = loadConfigFile('./benchmark.js')20} else if (env === 'testing') {21 config = loadConfigFile('./testing.js')22} else if (env === 'localTesting') {23 config = loadConfigFile('./localTesting.js')24} else {25 config = loadConfigFile('../local.js')26}...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

2const path = require('path');3const loadConfigFile = require('../../dist/loadConfigFile.js');4describe('loadConfigFile', () => {5 it('loads a config file', async () => {6 const { options, warnings } = await loadConfigFile(7 path.resolve(__dirname, 'samples/basic/rollup.config.js')8 );9 assert.strictEqual(warnings.count, 0);10 assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), [11 {12 external: [],13 input: 'my-input',14 output: [15 {16 file: 'my-file',17 format: 'es',18 plugins: []19 }20 ],...

Full Screen

Full Screen

loadConfigFile.js

Source:loadConfigFile.js Github

copy

Full Screen

...5 //////////////////////////////6 // loadConfigFile7 //////////////////////////////8 it('loadConfigFile', function (done) {9 var result = helpers.loadConfigFile('../../tests/testFile.txt'),10 expect = 'This is a test file that test\'s the loadConfigFile helper function.';11 assert.equal(expect, result);12 done();13 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var availableConfigFiles = require("availableConfigFiles");2availableConfigFiles.loadConfigFile("testConfig.json", function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9{10}11{ name: 'testConfig', value: 'testValue' }12var availableConfigFiles = require("availableConfigFiles");13availableConfigFiles.loadConfigFile("testConfig.json", function(err, data) {14 if (err) {15 console.log(err);16 } else {17 console.log(data);18 }19});20{21}22{ name: 'testConfig', value: 'testValue' }23var availableConfigFiles = require("availableConfigFiles");24availableConfigFiles.loadConfigFile("testConfig.json", function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 }30});31{32}33{ name: 'testConfig', value: 'testValue' }34var availableConfigFiles = require("availableConfigFiles");35availableConfigFiles.loadConfigFile("testConfig.json", function(err, data) {36 if (err) {37 console.log(err);38 } else {39 console.log(data);40 }41});42{43}44{ name: 'testConfig', value: 'testValue' }45var availableConfigFiles = require("availableConfigFiles");46availableConfigFiles.loadConfigFile("testConfig.json", function(err, data) {47 if (err) {48 console.log(err);49 } else {50 console.log(data);

Full Screen

Using AI Code Generation

copy

Full Screen

1var availableConfigFiles = require('available-config-files');2var config = availableConfigFiles.loadConfigFile('config.json', 'test');3{4}5{6}7### loadConfigFile(configFileName, [configFilePath])

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 ava 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