How to use loadConfiguration method in stryker-parent

Best JavaScript code snippet using stryker-parent

configuration.test.js

Source:configuration.test.js Github

copy

Full Screen

2import { jest } from '@jest/globals'3import { join, resolve } from 'path'4import { cwd } from 'process'5import { loadConfiguration } from '../../src/services/configuration.js'6describe('loadConfiguration()', () => {7 const { ...envSave } = process.env8 const jwtKey = faker.internet.password()9 const turnSecret = faker.lorem.words()10 const githubId = faker.datatype.uuid()11 const githubSecret = faker.internet.password()12 const googleId = faker.datatype.uuid()13 const googleSecret = faker.internet.password()14 beforeEach(() => {15 process.env = { ...envSave }16 jest.spyOn(console, 'warn').mockImplementation(() => {})17 })18 it('loads values from environment variables', () => {19 const port = faker.datatype.number({ min: 0, max: 8000 })20 const host = faker.internet.ip()21 const level = faker.helpers.arrayElement([22 'fatal',23 'error',24 'info',25 'debug'26 ])27 const gamesPath = faker.system.directoryPath()28 const dataPath = faker.system.directoryPath()29 const key = faker.system.filePath()30 const cert = faker.system.filePath()31 const domain = faker.internet.url()32 const allowedOrigins = faker.internet.url()33 process.env = {34 ...process.env,35 DATA_PATH: dataPath,36 AUTH_DOMAIN: domain,37 ALLOWED_ORIGINS_REGEXP: allowedOrigins,38 GAMES_PATH: gamesPath,39 GITHUB_ID: githubId,40 GITHUB_SECRET: githubSecret,41 GOOGLE_ID: googleId,42 GOOGLE_SECRET: googleSecret,43 HOST: host,44 HTTPS_CERT: cert,45 HTTPS_KEY: key,46 JWT_KEY: jwtKey,47 LOG_LEVEL: level,48 PORT: port,49 TURN_SECRET: turnSecret50 }51 expect(loadConfiguration()).toEqual({52 isProduction: false,53 serverUrl: { host, port },54 logger: { level },55 https: { key, cert },56 plugins: {57 graphql: {58 graphiql: 'playground',59 allowedOrigins60 },61 static: { path: gamesPath, pathPrefix: '/games' },62 cors: { allowedOrigins }63 },64 games: { path: gamesPath },65 data: { path: dataPath },66 turn: { secret: turnSecret },67 auth: {68 domain,69 allowedOrigins,70 jwt: { key: jwtKey },71 github: { id: githubId, secret: githubSecret },72 google: { id: googleId, secret: googleSecret }73 }74 })75 })76 it('loads production default values', () => {77 process.env = {78 ...process.env,79 NODE_ENV: 'production',80 JWT_KEY: jwtKey,81 TURN_SECRET: turnSecret,82 GITHUB_ID: githubId,83 GITHUB_SECRET: githubSecret,84 GOOGLE_ID: googleId,85 GOOGLE_SECRET: googleSecret86 }87 const allowedOrigins =88 '^https:\\/\\/(?:(?:.+\\.)?tabulous\\.(?:fr|games)|tabulous(?:-.+)?\\.vercel\\.app)'89 expect(loadConfiguration()).toEqual({90 isProduction: true,91 serverUrl: {92 host: '0.0.0.0',93 port: 300194 },95 logger: { level: 'debug' },96 https: null,97 plugins: {98 graphql: { graphiql: null, allowedOrigins },99 static: {100 path: resolve(cwd(), '..', 'games'),101 pathPrefix: '/games'102 },103 cors: { allowedOrigins }104 },105 games: { path: resolve(cwd(), '..', 'games') },106 data: { path: resolve(cwd(), 'data') },107 turn: { secret: turnSecret },108 auth: {109 domain: 'https://auth.tabulous.fr',110 allowedOrigins,111 jwt: { key: jwtKey },112 github: { id: githubId, secret: githubSecret },113 google: { id: googleId, secret: googleSecret }114 }115 })116 })117 it('reports missing variables', () => {118 process.env.NODE_ENV = 'production'119 expect(loadConfiguration).toThrow(`/turn must have property 'secret'`)120 expect(loadConfiguration).toThrow(`/auth/jwt must have property 'key'`)121 })122 describe('given required environment values', () => {123 beforeEach(() => {124 process.env.TURN_SECRET = turnSecret125 })126 it('loads development default values', () => {127 const allowedOrigins = '^https?:\\/\\/localhost:\\d+'128 expect(loadConfiguration()).toEqual({129 isProduction: false,130 serverUrl: {131 port: 3001132 },133 logger: { level: 'debug' },134 https: null,135 plugins: {136 graphql: {137 graphiql: 'playground',138 allowedOrigins139 },140 static: {141 path: resolve(cwd(), '..', 'games'),142 pathPrefix: '/games'143 },144 cors: { allowedOrigins }145 },146 games: { path: resolve(cwd(), '..', 'games') },147 data: { path: resolve(cwd(), 'data') },148 turn: { secret: turnSecret },149 auth: {150 jwt: { key: 'dummy-test-key' },151 domain: 'http://localhost:3001',152 allowedOrigins153 }154 })155 })156 it('conditionally loads Github auth provider details', () => {157 process.env = {158 ...process.env,159 GITHUB_ID: githubId,160 GITHUB_SECRET: githubSecret161 }162 expect(loadConfiguration().auth).toEqual({163 domain: 'http://localhost:3001',164 allowedOrigins: '^https?:\\/\\/localhost:\\d+',165 jwt: { key: 'dummy-test-key' },166 github: { id: githubId, secret: githubSecret }167 })168 })169 it('conditionally loads Google auth provider details', () => {170 process.env = {171 ...process.env,172 GOOGLE_ID: googleId,173 GOOGLE_SECRET: googleSecret174 }175 expect(loadConfiguration().auth).toEqual({176 domain: 'http://localhost:3001',177 allowedOrigins: '^https?:\\/\\/localhost:\\d+',178 jwt: { key: 'dummy-test-key' },179 google: { id: googleId, secret: googleSecret }180 })181 })182 it('validates PORT variable', () => {183 process.env.PORT = 'invalid'184 expect(loadConfiguration).toThrow('/serverUrl/port must be uint16')185 process.env.PORT = -100186 expect(loadConfiguration).toThrow('/serverUrl/port must be uint16')187 })188 it('validates LOG_LEVEL variable', () => {189 process.env.LOG_LEVEL = 'invalid'190 expect(loadConfiguration).toThrow(191 '/logger/level must be equal to one of the allowed values'192 )193 process.env.PORT = true194 expect(loadConfiguration).toThrow(195 '/logger/level must be equal to one of the allowed values'196 )197 })198 it('considers GAMES_PATH relatively to current working directory', () => {199 process.env.CLIENT_ROOT = join('.', 'test')200 process.env.GAMES_PATH = join('.', 'test2')201 expect(loadConfiguration().plugins.static.path).toEqual(202 join(cwd(), 'test2')203 )204 expect(loadConfiguration().games.path).toEqual(join(cwd(), 'test2'))205 })206 it('considers DATA_PATH relatively to current working directory', () => {207 process.env.TURN_SECRET = faker.lorem.words()208 process.env.DATA_PATH = './test'209 expect(loadConfiguration().data.path).toEqual(join(cwd(), 'test'))210 })211 })...

Full Screen

Full Screen

tests.js

Source:tests.js Github

copy

Full Screen

...66 const err = await t.throws(p.loadContext({err: promise}));67 t.is(err.message, 'ERROR');68});69test('loadConfiguration: should load config from package.json', async t => {70 const {context, prompt, bannerFunc} = await p.loadConfiguration({71 package: path.join(__dirname, 'pkg.json'),72 replrc: false,73 });74 t.deepEqual(context, {bar: 42});75 t.is(prompt, '<TEST> $');76 t.true(typeof bannerFunc === 'function');77});78test('loadConfiguration: should allow "repl" config to be an array in package.json', async t => {79 const {context, prompt, bannerFunc} = await p.loadConfiguration({80 package: path.join(__dirname, 'pkg-with-repl-array.json'),81 replrc: false,82 });83 t.is(context.bar, 42);84 t.is(prompt, '[foo] > ');85 t.true(typeof bannerFunc === 'function');86 t.true(typeof context.lodash === 'function');87});88test('loadConfiguration: should allow "repl" config to be an array in replrc', async t => {89 const {context} = await p.loadConfiguration({90 package: false,91 replrc: path.join(__dirname, 'replrc-with-array.js'),92 });93 t.is(context.bar, 43);94 t.true(typeof context.lodash === 'function');95});96test('loadConfiguration: should load config from a replrc file', async t => {97 const {context, prompt} = await p.loadConfiguration({98 package: false,99 replrc: path.join(__dirname, 'replrc.js'),100 });101 t.is(context.bar, 43);102 t.true(typeof context.lodash === 'function');103 t.is(prompt, '[TEST] $');104});105test('loadConfiguration: should give precedence to replrc file', async t => {106 const {context, bannerFunc} = await p.loadConfiguration({107 package: path.join(__dirname, 'pkg.json'),108 replrc: path.join(__dirname, 'replrc.js'),109 });110 t.is(context.bar, 43);111 t.true(typeof context.lodash === 'function');112 const banner = bannerFunc();113 t.is(banner, 'TEST');114});115test('loadConfiguration: should allow prompts to be defined as a function', async t => {116 const {context, promptFunc, package: pkg} = await p.loadConfiguration({117 package: path.join(__dirname, 'pkg.json'),118 replrc: path.join(__dirname, 'replrc-with-prompt-func.js'),119 });120 t.is(context.foo, 'TEST');121 t.true(typeof promptFunc === 'function');122 t.is(promptFunc(context, pkg), 'TEST foo > ');123});124test('loadConfiguration: should allow context to be an object', async t => {125 const {context} = await p.loadConfiguration({126 package: path.join(__dirname, 'pkg.json'),127 replrc: path.join(__dirname, 'replrc-with-context-obj.js'),128 });129 t.true(typeof context.l === 'function');130 t.is(context.meaningOfLife, 42);131});132test('loadConfiguration: should give precedence to passed options', async t => {133 const {prompt, banner} = await p.loadConfiguration({134 package: path.join(__dirname, 'pkg.json'),135 replrc: path.join(__dirname, 'replrc.js'),136 prompt: 'override > ',137 banner: 'OVERRIDE',138 });139 t.is(prompt, 'override > ');140 t.is(banner, 'OVERRIDE');141});142test('contextKey: should camelcase local paths with dashes', t => {143 t.is(p.contextKey('./utils/foo-bar'), 'fooBar');144 t.is(p.contextKey('/utils/foo-bar'), 'fooBar');145});146test('contextKey: should camelcase snakecase names', t => {147 t.is(p.contextKey('./utils/foo_bar'), 'fooBar');...

Full Screen

Full Screen

loadConfiguration-test.js

Source:loadConfiguration-test.js Github

copy

Full Screen

...4 beforeEach( () => {5 loadConfiguration = require('../loadConfiguration')6 })7 it('should fail if package.proof is not defined', () => {8 expect( () => loadConfiguration({})).toThrow()9 })10 it('should extract configuration from specification in package', () => {11 const pkg = {12 other_prop: {},13 proof: {14 CONTENT_API_TOKEN: 'a',15 AWS_ACCESS_KEY_ID: 'b',16 arbitrary: {17 props: true,18 },19 }20 }21 const config = loadConfiguration(pkg)22 expect(config).toEqual(pkg.proof)23 })24 it('should ignore configurations when unspecified', () => {25 const pkg = {26 other_prop: {},27 proof: {28 CONTENT_API_TOKEN: 'a',29 AWS_ACCESS_KEY_ID: 'b',30 arbitrary: {31 props: true,32 },33 configurations: {34 production: {35 CONTENT_API_TOKEN: 'c',36 },37 staging: {38 CONTENT_API_TOKEN: 'd',39 },40 },41 },42 }43 const config = loadConfiguration(pkg)44 expect(config).toEqual({45 CONTENT_API_TOKEN: 'a',46 AWS_ACCESS_KEY_ID: 'b',47 arbitrary: {48 props: true,49 },50 })51 })52 it('should composite a configuration if a name is specified', () => {53 const pkg = {54 other_prop: {},55 proof: {56 CONTENT_API_TOKEN: 'a',57 AWS_ACCESS_KEY_ID: 'b',58 arbitrary: {59 props: true,60 },61 configurations: {62 production: {63 CONTENT_API_TOKEN: 'c',64 },65 staging: {66 CONTENT_API_TOKEN: 'd',67 },68 },69 },70 }71 const config = loadConfiguration(pkg, 'production')72 expect(config).toEqual({73 AWS_ACCESS_KEY_ID: 'b',74 arbitrary: {75 props: true,76 },77 CONTENT_API_TOKEN: 'c',78 })79 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const loadConfiguration = require('stryker-parent').loadConfiguration;2const strykerConfig = loadConfiguration('stryker.conf.js');3const loadConfiguration = require('stryker').loadConfiguration;4const strykerConfig = loadConfiguration('stryker.conf.js');5interface StrykerOptions extends StrictStrykerOptions {6 mutate: string[];7 files: string[];8}9interface StrictStrykerOptions extends StrykerOptions {10 [key: string]: any;11 checkers?: string[];12 coverageAnalysis?: 'off' | 'all' | 'perTest' | 'on';13 coverageAnalysis?: 'off' | 'all' | 'perTest' | 'on';14 coverageAnalysis?: 'off' | 'all' | 'perTest' | 'on';15 coverageAnalysis?: 'off' | 'all' | 'perTest' | 'on';16 dashboard?: DashboardOptions;

Full Screen

Using AI Code Generation

copy

Full Screen

1const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');2const configuration = require('stryker').loadConfiguration('stryker.conf.js');3module.exports = function (config) {4 const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');5 const configuration = require('stryker').loadConfiguration('stryker.conf.js');6}7const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');8const configuration = require('stryker').loadConfiguration('stryker.conf.js');9const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');10module.exports = function (config) {11 const configuration = require('stryker').loadConfiguration('stryker.conf.js');12}13const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');14const configuration = require('stryker').loadConfiguration('stryker.conf.js');15const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');16const configuration = require('stryker').loadConfiguration('stryker.conf.js');17const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');18const configuration = require('stryker').loadConfiguration('stryker.conf.js');19const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');20const configuration = require('stryker').loadConfiguration('stryker.conf.js');21const configuration = require('stryker-parent').loadConfiguration('stryker.conf.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.loadConfiguration('stryker.conf.js', function(error, config) {3 if (error) {4 console.error('Failed to load configuration');5 } else {6 console.log('Loaded configuration');7 }8});9var stryker = require('stryker');10stryker.loadConfiguration('stryker.conf.js', function(error, config) {11 if (error) {12 console.error('Failed to load configuration');13 } else {14 console.log('Loaded configuration');15 }16});17module.exports = function(config) {18 config.set({19 karma: {20 config: {21 }22 }23 });24};25module.exports = function(config) {26 config.set({27 preprocessors: {28 },29 coverageReporter: {30 },31 });32};33{34 "scripts": {35 },36 "devDependencies": {

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