How to use configReader method in stryker-parent

Best JavaScript code snippet using stryker-parent

package-json-config-reader.spec.ts

Source:package-json-config-reader.spec.ts Github

copy

Full Screen

1import * as chai from 'chai';2import * as chaiAspromised from 'chai-as-promised';3chai.use(chaiAspromised);4import { assert, expect } from 'chai';5import * as fs from 'fs';6import 'mocha';7import * as mockfs from 'mock-fs';8import * as path from 'path';9import PackageJsonConfigReader, { ERRORS } from './package-json-config-reader';10describe('PackageJsonConfigReader', () => {11 const testDir = '/tmp/tests/';12 const priorConfiguredFile = 'priorConfiguredFile.json';13 const noConfigFile = 'noConfigFile.json';14 const noFrontvueConfigFile = 'noFrontVueConfigFile.json';15 const nonExistingFile = 'nonExistingConfigFile.json';16 const readonlyConfigFile = 'readonlyConfigFile.json';17 // Restore FileSystem18 before(mockfs.restore);19 // Mock FileSystem with dummy files20 beforeEach(() => {21 mockfs.restore();22 const noConfigContent = '{}';23 const noFrontvueConfigContent = `{ "config": { "somePlugin": {} } }`;24 const withConfigContent = `{ "config": { "frontvue": { "key": "value" } } }`;25 mockfs({26 [testDir]: {27 [noConfigFile]: noConfigContent,28 [noFrontvueConfigFile]: noFrontvueConfigContent,29 [priorConfiguredFile]: withConfigContent,30 [readonlyConfigFile]: mockfs.file({ content: withConfigContent, mode: 0o440 }),31 },32 });33 });34 // Clean up35 afterEach(mockfs.restore);36 after(async () => {37 return PackageJsonConfigReader('frontvue')38 .then(configReader => configReader.destroy());39 });40 it('instantiates with no namespace', () => {41 // Reading actual package.json from current folder42 mockfs.restore();43 return expect(PackageJsonConfigReader())44 .to.eventually.have.all.keys('destroy', 'fetch', 'update');45 });46 it('throws if namespace is not a string', () => {47 // Reading actual package.json from current folder48 mockfs.restore();49 return expect(PackageJsonConfigReader(1))50 .to.be.rejectedWith(ERRORS.INVALID_NAMESPACE);51 });52 it('instantiates with no custom filepath', () => {53 // Reading actual package.json from current folder54 mockfs.restore();55 return expect(PackageJsonConfigReader('frontvue'))56 .to.eventually.be.an('object')57 .to.eventually.have.all.keys('destroy', 'fetch', 'update');58 });59 it('instantiates without any config object', async () => {60 const filepath = path.join(testDir, noConfigFile);61 const configReader = await PackageJsonConfigReader('frontvue', filepath);62 const config = await configReader.fetch();63 const fileContents = fs.readFile(filepath, { encoding: 'utf-8' }, (error, data) => {64 expect(JSON.parse(data)).to.eql({config: { frontvue: {} }});65 });66 }).timeout(12000);67 it('instantiates without Frontvue config object', async () => {68 const filepath = path.join(testDir, noFrontvueConfigFile);69 const configReader = await PackageJsonConfigReader('frontvue', filepath);70 const config = await configReader.fetch();71 const fileContents = await fs.readFile(filepath, { encoding: 'utf-8' }, (error, data) => {72 expect(JSON.parse(data)).to.eql({config: { somePlugin: {}, frontvue: {} }});73 });74 }).timeout(12000);75 it('instantiates with prior Frontvue config object', async () => {76 const filepath = path.join(testDir, priorConfiguredFile);77 const configReader = await PackageJsonConfigReader('frontvue', filepath);78 return expect(configReader.fetch()).to.eventually.eql({ key: 'value' });79 });80 it('updates config object', async () => {81 const filepath = path.join(testDir, noConfigFile);82 const configReader = await PackageJsonConfigReader('frontvue', filepath);83 const updated = await configReader.update({ key: 'value' });84 return expect(configReader.fetch()).to.eventually.eql({ key: 'value' });85 });86 it('removes config from file and returns it', async () => {87 const filepath = path.join(testDir, priorConfiguredFile);88 const configReader = await PackageJsonConfigReader('frontvue', filepath);89 expect(await configReader.destroy()).to.eql({ key: 'value' });90 expect(await configReader.fetch()).to.be.undefined;91 });92 it('rejects promise if filepath config file can\'t be read', () => {93 return expect(PackageJsonConfigReader('frontvue', path.join(testDir, nonExistingFile)))94 .to.be.rejectedWith(RegExp(ERRORS.RW_ERROR));95 }).timeout(12000);96 it('rejects promise if refetching config from file fails', async () => {97 const filepath = path.join(testDir, priorConfiguredFile);98 const configReader = await PackageJsonConfigReader('frontvue', filepath);99 // We destroy the mocked fs and replace the file with something that can't be read100 mockfs.restore();101 mockfs({102 [testDir]: {103 [priorConfiguredFile]: '',104 },105 });106 return expect(configReader.fetch()).to.be.rejectedWith(RegExp(ERRORS.RW_ERROR));107 }).timeout(12000);108 it('rejects promise if destroy fails after initial config file fetch', async () => {109 const filepath = path.join(testDir, priorConfiguredFile);110 const configReader = await PackageJsonConfigReader('frontvue', filepath);111 // We destroy the mocked fs and recreate the file with something that can't be read112 mockfs.restore();113 mockfs({114 [testDir]: {115 [priorConfiguredFile]: mockfs.file({116 content: 'File content',117 mode: 0o330,118 }),119 },120 });121 return expect(configReader.destroy()).to.be.rejectedWith(RegExp(ERRORS.RW_ERROR));122 }).timeout(12000);123 it('rejects promise if trying to destroy from readonly file', async () => {124 const filepath = path.join(testDir, readonlyConfigFile);125 const configReader = await PackageJsonConfigReader('frontvue', filepath);126 return expect(configReader.destroy()).to.be.rejectedWith(Error);127 }).timeout(12000);...

Full Screen

Full Screen

ConfigReader.ts

Source:ConfigReader.ts Github

copy

Full Screen

1import readlineSync from 'readline-sync';2import fs from 'fs';3import { resolve } from 'path';4import nodemailer from 'nodemailer';5export interface Config {6 url: string,7 port: number,8 language: string,9 logpath: string,10 enableRegistration: boolean,11 tokens: {12 accessTokenExpirationTime: number,13 refreshTokenExpirationTime: number,14 authorizationCodeExpirationTime: number,15 accessTokenLength: number,16 refreshTokenLength: number17 },18 db: {19 dbms: string,20 path: string,21 host: string,22 user: string,23 password: string,24 database: string,25 },26 email: {27 enabled: boolean,28 from: string,29 host: string,30 port: number,31 ssl: boolean,32 username: string,33 password: string,34 name: string35 },36 emailWhitelist: string[],37 user_info: any,38 custom: {39 logo: string,40 name: string,41 url: string42 }43}44export class ConfigReader {45 public static config: Config = {46 url: "",47 port: 3000,48 language: "en",49 logpath: resolve(__dirname + "/../logs"),50 enableRegistration: true,51 tokens: {52 accessTokenExpirationTime: 604800,53 refreshTokenExpirationTime: 2592000,54 authorizationCodeExpirationTime: 600,55 accessTokenLength: 50,56 refreshTokenLength: 5057 },58 db: {59 dbms: "sqlite",60 path: "",61 host: "",62 user: "",63 password: "",64 database: ""65 },66 email: {67 enabled: false,68 from: "",69 host: "",70 port: 587,71 ssl: false,72 username: "",73 password: "",74 name: ""75 },76 emailWhitelist: [],77 user_info: {},78 custom: {79 logo: "",80 name: "",81 url: ""82 }83 };84 public static transporter: any;85 public static load(path: string) {86 path = resolve(path);87 if (!path.endsWith('.json'))88 path += '.json';89 if (fs.existsSync(path))90 ConfigReader.config = Object.assign(ConfigReader.config, require(path));91 else92 ConfigReader.generateConfig(path);93 if (ConfigReader.config.email.enabled) {94 ConfigReader.transporter = nodemailer.createTransport({95 host: ConfigReader.config.email.host,96 port: ConfigReader.config.email.port,97 secure: ConfigReader.config.email.ssl,98 auth: {99 user: ConfigReader.config.email.username,100 pass: ConfigReader.config.email.password101 }102 });103 }104 }105 public static generateConfig(path: string) {106 console.log("db config");107 let dbconf = () => {108 ConfigReader.config.db.dbms = readlineSync.question("Which Database do you want to use? [mysql/sqlite]");109 if (ConfigReader.config.db.dbms === "mysql") {110 ConfigReader.config.db.host = readlineSync.question("host: ");111 ConfigReader.config.db.user = readlineSync.question("username: ");112 ConfigReader.config.db.password = readlineSync.question("password: ");113 ConfigReader.config.db.database = readlineSync.question("database name: ");114 return true;115 } else if (ConfigReader.config.db.dbms === "sqlite") {116 ConfigReader.config.db.path = readlineSync.question("path: ");117 return true;118 } else {119 return false;120 }121 }122 while (!dbconf()) { }123 console.log("\nServer config");124 let emails = readlineSync.question("email address domains on whitelist separated by commas [empty]: ") || "";125 ConfigReader.config.emailWhitelist = emails.split(",");126 ConfigReader.config.url = readlineSync.question("url of the Server (e.g. https://example.com/oauth): ");127 ConfigReader.config.language = readlineSync.question("default website language [en]: ") || "en";128 console.log("\nEmail config");129 let emailEnabled = readlineSync.question("Do you want to send email address verification emails? [y/n] ");130 if (emailEnabled.toLowerCase() === "y") {131 ConfigReader.config.email.enabled = true;132 ConfigReader.config.email.from = readlineSync.question("from which email address do you want to send the emails? ");133 ConfigReader.config.email.host = readlineSync.question("SMTP Server address: ");134 ConfigReader.config.email.port = readlineSync.question("SMTP Server port: ");135 ConfigReader.config.email.ssl = readlineSync.question("Does the server use SSL/TLS (Not STARTTLS)? [y/n] ").toLocaleLowerCase() == "y";136 ConfigReader.config.email.username = readlineSync.question("SMTP username: ");137 ConfigReader.config.email.password = readlineSync.question("password: ");138 ConfigReader.config.email.name = readlineSync.question("Display name: ");139 } else {140 ConfigReader.config.email.enabled = false;141 }142 let ok = readlineSync.question(JSON.stringify(ConfigReader.config, null, 4) + "\nShould this config be saved? [y/n] ");143 if (ok.toLowerCase() === "y") {144 fs.writeFileSync(path, JSON.stringify(ConfigReader.config, null, 4));145 } else {146 ConfigReader.generateConfig(path);147 }148 }...

Full Screen

Full Screen

ConfigServiceImpl.ts

Source:ConfigServiceImpl.ts Github

copy

Full Screen

1import { injectable } from "@parisholley/inversify-async";2import { container } from "../config/inversify.config";3import { types } from "../config/types";4import { ConfigReader } from "../ConfigReader";5import { ConfigService } from "./ConfigService";6@injectable()7export class ConfigServiceImpl implements ConfigService {8 async isAutoPronunciationWhenReview(): Promise<boolean> {9 const configReader = await container.getAsync<ConfigReader>(ConfigReader);10 return configReader.getBoolean("autoPronunciation");11 }12 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var configReader = require('stryker-parent').configReader;2var config = configReader.readConfig();3var configReader = require('stryker-child').configReader;4var config = configReader.readConfig();5var configReader = function() {6 var config = require('../../stryker.conf.js');7 return config;8}9module.exports = {10}11var Stryker = require('stryker');12var configReader = require('./configReader');13var config = configReader.readConfig();14var stryker = new Stryker(config);15stryker.runMutationTest();16module.exports = {17}18var configReader = require('./lib/configReader');19var stryker = require('./lib/stryker');20module.exports = {21}22module.exports = function(config) {23 config.set({24 });25};26module.exports = function(config) {27 config.set({

Full Screen

Using AI Code Generation

copy

Full Screen

1var configReader = require('stryker-parent').configReader;2configReader.readConfig('test.json');3{4}5var Stryker = require('stryker');6var config = configReader.readConfig('test.json');7var stryker = new Stryker(config);8var Stryker = require('stryker');9var config = configReader.readConfig('test.json');10var stryker = new Stryker(config);11stryker.runMutationTest();12var Stryker = require('stryker');13var config = configReader.readConfig('test.json');14var stryker = new Stryker(config);15stryker.runMutationTest().then(function (result) {16 console.log(result);17});

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 stryker-parent 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