Best JavaScript code snippet using stryker-parent
create-window.ts
Source:create-window.ts
1import path from 'path'2import { BrowserWindow, BrowserWindowConstructorOptions } from 'electron'3import { log } from '../log'4import routes from '@/src/auto-routes'5const { NODE_ENV, port, host } = process.env6/** å建æ°çªå£ç¸å
³é项 */7export interface CreateWindowOptions {8 /** è·¯ç±å¯å¨åæ° */9 params?: any10 /** URL å¯å¨åæ° */11 query?: any12 /** BrowserWindow é项 */13 windowOptions?: BrowserWindowConstructorOptions14 /** çªå£å¯å¨åæ° */15 createConfig?: CreateConfig16}17/** å·²å建ççªå£å表 */18export const windowList: Map<RouterKey, BrowserWindow> = new Map()19/**20 * éè¿ routes ä¸ç key(name) å¾å° url21 * @param key22 */23export function getWindowUrl(key: RouterKey, options: CreateWindowOptions = {}): string {24 let routePath = routes.get(key)?.path25 if (typeof routePath === 'string' && options.params) {26 routePath = routePath.replace(/\:([^\/]+)/g, (_, $1) => {27 return options.params[$1]28 })29 }30 const query = options.query ? $tools.toSearch(options.query) : ''31 if (NODE_ENV === 'development') {32 return `http://${host}:${port}#${routePath}${query}`33 } else {34 return `file://${path.join(__dirname, '../renderer/index.html')}#${routePath}${query}`35 }36}37/**38 * å建ä¸ä¸ªæ°çªå£39 * @param key40 * @param options41 */42export function createWindow(key: RouterKey, options: CreateWindowOptions = {}): Promise<BrowserWindow> {43 return new Promise((resolve) => {44 const routeConfig: RouteConfig | AnyObj = routes.get(key) || {}45 const windowOptions: BrowserWindowConstructorOptions = {46 ...$tools.DEFAULT_WINDOW_OPTIONS, // é»è®¤æ°çªå£é项47 ...routeConfig.windowOptions, // routes ä¸çé
ç½®çwindowé项48 ...options.windowOptions, // è°ç¨æ¹æ³æ¶ä¼ å
¥çé项49 }50 const createConfig: CreateConfig = {51 ...$tools.DEFAULT_CREATE_CONFIG,52 ...routeConfig.createConfig,53 ...options.createConfig,54 }55 let activeWin: BrowserWindow | boolean56 if (createConfig.single) {57 activeWin = activeWindow(key)58 if (activeWin) {59 resolve(activeWin)60 return activeWin61 }62 }63 const win = new BrowserWindow(windowOptions)64 const url = getWindowUrl(key, options)65 windowList.set(key, win)66 win.loadURL(url)67 if (createConfig.saveWindowBounds) {68 const lastBounds = $tools.settings.windowBounds.get(key)69 if (lastBounds) win.setBounds(lastBounds)70 }71 if (createConfig.hideMenus) win.setMenuBarVisibility(false)72 if (createConfig.created) createConfig.created(win)73 win.webContents.on('dom-ready', () => {74 win.webContents.send('dom-ready', createConfig)75 })76 win.webContents.on('did-finish-load', () => {77 if (createConfig.autoShow) {78 if (createConfig.delayToShow) {79 setTimeout(() => {80 win.show()81 }, createConfig.delayToShow)82 } else {83 win.show()84 }85 }86 resolve(win)87 })88 win.once('ready-to-show', () => {89 if (createConfig.openDevTools) win.webContents.openDevTools()90 })91 win.once('show', () => {92 log.info(`Window <${key}:${win.id}> url: ${url} opened.`)93 })94 win.on('close', () => {95 if (createConfig.saveWindowBounds && win) {96 $tools.settings.windowBounds.set(key, win.getBounds())97 }98 windowList.delete(key)99 log.info(`Window <${key}:${win.id}> closed.`)100 })101 })102}103/**104 * æ¿æ´»ä¸ä¸ªå·²åå¨ççªå£, æåè¿å BrowserWindow 失败è¿å false105 * @param key106 */107export function activeWindow(key: RouterKey): BrowserWindow | false {108 const win: BrowserWindow | undefined = windowList.get(key)109 if (win) {110 win.show()111 return win112 } else {113 return false114 }...
config-test.js
Source:config-test.js
1var Config = require('../../../lib/models/config');2var expect = require('chai').expect;3describe('Config', function() {4 function createConfig(projectName, configJson) {5 return new Config({6 project: { name: function(){ return projectName; } },7 rawConfig: configJson8 });9 }10 describe('manifestPrefix', function(){11 it('defaults to project name', function() {12 var config = createConfig('tomster', {});13 expect(config.get('manifestPrefix')).to.eq('tomster');14 });15 it('allows configuration', function() {16 var config = createConfig('tomster', { manifestPrefix: 'seldenator' });17 expect(config.get('manifestPrefix')).to.eq('seldenator');18 });19 });20 describe('buildEnv', function(){21 it('defaults to production', function() {22 var config = createConfig('tomster', {});23 expect(config.get('buildEnv')).to.eq('production');24 });25 it('allows configuration', function() {26 var config = createConfig('tomster', { buildEnv: 'chocula' });27 expect(config.get('buildEnv')).to.eq('chocula');28 });29 });30 describe('store.type', function(){31 it('defaults to redis', function() {32 var config = createConfig('tomster', {});33 expect(config.get('store.type')).to.eq('redis');34 });35 it('allows configuration', function() {36 var config = createConfig('tomster', { store: { type: 'cassandra' } });37 expect(config.get('store.type')).to.eq('cassandra');38 });39 });40 describe('store.manifestSize', function(){41 it('defaults to 10', function() {42 var config = createConfig('tomster', {});43 expect(config.get('store.manifestSize')).to.eq(10);44 });45 it('allows configuration', function() {46 var config = createConfig('tomster', { store: { manifestSize: 42 } });47 expect(config.get('store.manifestSize')).to.eq(42);48 });49 });50 describe('assets.type', function(){51 it('defaults to s3', function() {52 var config = createConfig('tomster', {});53 expect(config.get('assets.type')).to.eq('s3');54 });55 it('allows configuration', function() {56 var config = createConfig('tomster', { assets: { type: 'akamai' } });57 expect(config.get('assets.type')).to.eq('akamai');58 });59 });60 describe('assets.gzip', function(){61 it('defaults to true', function() {62 var config = createConfig('tomster', {});63 expect(config.get('assets.gzip')).to.eq(true);64 });65 it('allows configuration', function() {66 var config = createConfig('tomster', { assets: { gzip: false } });67 expect(config.get('assets.gzip')).to.eq(false);68 });69 });70 describe('assets.gzipExtensions', function(){71 it('defaults to js,css,svg', function() {72 var config = createConfig('tomster', {});73 expect(config.get('assets.gzipExtensions')).to.deep.equal(['js', 'css', 'svg']);74 });75 it('allows configuration', function() {76 var config = createConfig('tomster', { assets: { gzipExtensions: ['js', 'css'] } });77 expect(config.get('assets.gzipExtensions')).to.deep.equal(['js', 'css']);78 });79 });80 describe('tagging', function(){81 it('defaults to sha', function() {82 var config = createConfig('tomster', {});83 expect(config.get('tagging')).to.equal('sha');84 });85 it('allows configuration', function() {86 var config = createConfig('tomster', { tagging: 'yapp-custom' });87 expect(config.get('tagging')).to.equal('yapp-custom');88 });89 });...
Using AI Code Generation
1var createConfig = require('stryker-parent').createConfig;2var config = createConfig();3config.set({4});5module.exports = config;6module.exports = require('./test');
Using AI Code Generation
1const createConfig = require('stryker-parent').createConfig;2module.exports = function (config) {3 config.set(createConfig({4 karma: {5 }6 }));7}
Using AI Code Generation
1const { createConfig } = require('stryker-parent');2module.exports = createConfig({3});4module.exports = require('./test.js');5module.exports = require('./test.js');6module.exports = require('./test.js');7module.exports = require('./test.js');8module.exports = require('./test.js');9module.exports = require('./test.js');10module.exports = require('./test.js');11module.exports = require('./test.js');12module.exports = require('./test.js');13module.exports = require('./test.js');14module.exports = require('./test.js');15module.exports = require('./test.js');16module.exports = require('./test.js');17module.exports = require('./test.js');18module.exports = require('./test.js');19module.exports = require('./test.js');20module.exports = require('./test.js');21module.exports = require('./test.js');22module.exports = require('./test.js');23module.exports = require('./test.js');24module.exports = require('./test.js');25module.exports = require('./test.js');26module.exports = require('./test.js');27module.exports = require('./test.js');28module.exports = require('./test.js');29module.exports = require('./test.js');30module.exports = require('./test.js');31module.exports = require('./test.js');32module.exports = require('./test.js');
Using AI Code Generation
1var createConfig = require('stryker-parent').createConfig;2var config = createConfig({3});4module.exports = config;5module.exports = require('./test.js');6var Stryker = require('stryker');7var stryker = new Stryker();8stryker.runMutationTest();9var Stryker = require('stryker');10var stryker = new Stryker(options);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!