How to use stryker method in stryker-parent

Best JavaScript code snippet using stryker-parent

stryker-cli.spec.ts

Source:stryker-cli.spec.ts Github

copy

Full Screen

1import * as path from 'path';2import { expect } from 'chai';3import chalk from 'chalk';4import * as sinon from 'sinon';5import * as inquirer from 'inquirer';6import * as resolve from 'resolve';7import * as child from 'child_process';8import NodeWrapper from '../../src/NodeWrapper';9import { run } from '../../src/stryker-cli';10describe('stryker-cli', () => {11 const basedir = '/apps/myapp';12 const strykerPackageJsonPath = 'apps/myapp/node_modules/@stryker-mutator/core/package.json';13 const strykerBinPath = 'apps/myapp/node_modules/@stryker-mutator/core/bin/stryker';14 const errorMessageModuleNotLoaded = `Error: Cannot find module '@stryker-mutator/core'`;15 let sandbox: sinon.SinonSandbox;16 let stubs: {17 prompt: sinon.SinonStub;18 execSync: sinon.SinonStub;19 require: sinon.SinonStub;20 resolve: sinon.SinonStub;21 log: sinon.SinonStub;22 error: sinon.SinonStub;23 cwd: sinon.SinonStub;24 };25 beforeEach(() => {26 sandbox = sinon.createSandbox();27 stubs = {28 cwd: sandbox.stub(NodeWrapper, 'cwd'),29 error: sandbox.stub(),30 execSync: sandbox.stub(child, 'execSync'),31 log: sandbox.stub(NodeWrapper, 'log'),32 prompt: sandbox.stub(inquirer, 'prompt'),33 require: sandbox.stub(NodeWrapper, 'require'),34 resolve: sandbox.stub(resolve, 'sync')35 };36 });37 afterEach(() => {38 sandbox.restore();39 });40 it('should pass commands through to local stryker', async () => {41 stubs.resolve.returns(path.resolve(strykerPackageJsonPath));42 stubs.cwd.returns(basedir);43 await run();44 expect(stubs.resolve).calledWith('@stryker-mutator/core/package.json', { basedir });45 expect(stubs.require).calledWith(path.resolve(strykerBinPath));46 });47 it('should prompt to install stryker if local stryker is not found', async () => {48 stubs.resolve.throws(new Error(errorMessageModuleNotLoaded));49 stubs.prompt.resolves({});50 await run();51 expect(stubs.prompt).calledWith([{52 choices: ['npm', 'yarn', 'no'],53 default: 'npm',54 message: 'Do you want to install Stryker locally?',55 name: 'install',56 type: 'list'57 }]);58 });59 it('should require local stryker after installing', async () => {60 stubs.resolve61 .onFirstCall().throws(new Error(errorMessageModuleNotLoaded))62 .onSecondCall().returns(path.resolve(strykerPackageJsonPath));63 stubs.prompt.resolves({ install: true });64 await run();65 expect(stubs.resolve).calledTwice;66 expect(stubs.require).calledWith(path.resolve(strykerBinPath));67 });68 it('should install stryker locally using npm if the user wants it', async () => {69 stubs.resolve70 .onFirstCall().throws(new Error(errorMessageModuleNotLoaded))71 .onSecondCall().returns(path.resolve(strykerPackageJsonPath));72 stubs.prompt.resolves({ install: 'npm' });73 await run();74 expect(stubs.execSync).calledWith('npm install --save-dev @stryker-mutator/core', { stdio: [0, 1, 2] });75 });76 it('should install stryker locally using yarn if the user wants it', async () => {77 stubs.resolve78 .onFirstCall().throws(new Error(errorMessageModuleNotLoaded))79 .onSecondCall().returns(path.resolve(strykerPackageJsonPath));80 stubs.prompt.resolves({ install: 'yarn' });81 await run();82 expect(stubs.execSync).calledWith('yarn add @stryker-mutator/core --dev', { stdio: [0, 1, 2] });83 });84 it('should not install stryker if the user didn\'t want it', async () => {85 stubs.resolve.throws(new Error(errorMessageModuleNotLoaded));86 stubs.prompt.resolves({ install: 'no' });87 await run();88 expect(stubs.execSync).not.called;89 expect(stubs.log).calledWith(`Ok, I don't agree, but I understand. You can install Stryker manually ` +90 `using ${chalk.blue('npm install --save-dev @stryker-mutator/core')}.`);91 });92 it('should pass all other errors', () => {93 stubs.resolve.returns(strykerPackageJsonPath);94 stubs.require.throws(new Error(`Error: Cannot find module 'FooBar'`));95 return expect(run()).rejectedWith(`Error: Cannot find module 'FooBar'`);96 });97 it('should not prompt again when failing a second time (with any error)', async () => {98 stubs.resolve.throws(new Error(errorMessageModuleNotLoaded));99 stubs.prompt.resolves({ install: true });100 await expect(run()).to.eventually.rejectedWith(errorMessageModuleNotLoaded);101 expect(stubs.resolve).calledTwice; // to verify that there actually was a second time102 expect(stubs.prompt).calledOnce; // the actual check103 expect(stubs.execSync).calledOnce;104 });...

Full Screen

Full Screen

stryker-cli.ts

Source:stryker-cli.ts Github

copy

Full Screen

1import * as path from 'path';2import chalk from 'chalk';3import * as inquirer from 'inquirer';4import * as child from 'child_process';5import NodeWrapper from './NodeWrapper';6import * as resolve from 'resolve';7const installCommands = {8 npm: 'npm install --save-dev @stryker-mutator/core',9 yarn: 'yarn add @stryker-mutator/core --dev'10};11export function run(): Promise<void> {12 try {13 return runLocalStryker();14 } catch (error) {15 if (error.toString().indexOf(`Cannot find module '@stryker-mutator/core`) >= 0) {16 return promptInstallStryker().then(packageManager => {17 if (packageManager !== undefined) {18 installStryker(installCommands[packageManager]);19 runLocalStryker();20 }21 });22 } else {23 // Oops, other error24 return Promise.reject(error);25 }26 }27}28function runLocalStryker() {29 const stryker = localStryker();30 NodeWrapper.require(stryker);31 return Promise.resolve();32}33function localStryker() {34 const stryker = resolve.sync('@stryker-mutator/core/package.json', { basedir: NodeWrapper.cwd() });35 const dirname = path.dirname(stryker);36 return path.resolve(dirname, './bin/stryker');37}38function promptInstallStryker(): Promise<'npm' | 'yarn' | undefined> {39 NodeWrapper.log(chalk.yellow('Stryker is currently not installed.'));40 return inquirer.prompt([{41 choices: ['npm', 'yarn', 'no'],42 default: 'npm',43 message: 'Do you want to install Stryker locally?',44 name: 'install',45 type: 'list'46 }]).then((answers: inquirer.Answers) => {47 if (answers.install === 'no') {48 NodeWrapper.log(`Ok, I don't agree, but I understand. You can install Stryker manually using ${chalk.blue(installCommands.npm)}.`);49 return undefined;50 } else {51 return answers.install;52 }53 });54}55function installStryker(installCommand: string) {56 printStrykerASCII();57 executeInstallStrykerProcess(installCommand);58}59function printStrykerASCII() {60 const strykerASCII =61 '\n' +62 chalk.yellow(' |STRYKER| ') + '\n' +63 chalk.yellow(' ~control the mutants~ ') + '\n' + '\n' +64 chalk.red(' ..####') + chalk.white('@') + chalk.red('####.. ') + '\n' +65 chalk.red(' .########') + chalk.white('@') + chalk.red('########. ') + '\n' +66 chalk.red(' .#####################. ') + '\n' +67 chalk.red(' #########') + chalk.yellow('#######') + chalk.red('######### ') + '\n' +68 chalk.red(' #########') + chalk.yellow('##') + chalk.red('#####') + chalk.yellow('##') + chalk.red('######### ') + '\n' +69 chalk.red(' #########') + chalk.yellow('##') + chalk.red('################ ') + '\n' +70 chalk.red(' ') + chalk.white('@@@') + chalk.red('#######') + chalk.yellow('#######') + chalk.red('#######') + chalk.white('@@@') + chalk.red(' ') + '\n' +71 chalk.red(' ################') + chalk.yellow('##') + chalk.red('######### ') + '\n' +72 chalk.red(' #########') + chalk.yellow('##') + chalk.red('#####') + chalk.yellow('##') + chalk.red('######### ') + '\n' +73 chalk.red(' #########') + chalk.yellow('#######') + chalk.red('######### ') + '\n' +74 chalk.red(` '######################' `) + '\n' +75 chalk.red(` '########`) + chalk.white('@') + chalk.red(`#########' `) + '\n' +76 chalk.red(` ''####`) + chalk.white('@') + chalk.red(`####'' `) + '\n';77 NodeWrapper.log(strykerASCII);78}79function executeInstallStrykerProcess(installCommand: string) {80 NodeWrapper.log(`${chalk.grey('Installing:')} ${installCommand}`);81 child.execSync(installCommand, { stdio: [0, 1, 2] });82 NodeWrapper.log(chalk.green('Stryker installation done.'));...

Full Screen

Full Screen

scriptManager.js

Source:scriptManager.js Github

copy

Full Screen

1/* jshint esversion: 6 */2var fs = require('fs');3var shell = require('shelljs');4var path = require('path');5var newLine = '\n';6var public = {};7public.testTranslate = function (test) {8 var resultFile = {};9 resultFile.name = "stryker.conf.js";10 var data = "module.exports = function(config) {" + newLine;11 data += " config.set({" + newLine;12 if(test.files && test.files.length > 0) {13 data += ` files: ["${test.files[0]}"`;14 for(var i = 1; i < test.files.length; i++){15 data += `, "${test.files[i]}"`;16 }17 data += `],` + newLine;18 }19 if(test.mutate && test.mutate.length > 0) {20 data += ` mutate: ["${test.mutate[0]}"`;21 for(var i = 1; i < test.mutate.length; i++){22 data += `, "${test.mutate[i]}"`;23 }24 data += `],` + newLine;25 }26 data += ` mutator: "${test.mutator}",` + newLine;27 data += " transpilers: []," + newLine;28 if(test.reporters && test.reporters.length > 0) {29 data += ` reporters: ["${test.reporters[0]}"`;30 for(var i = 1; i < test.reporters.length; i++){31 data += `, "${test.reporters[i]}"`;32 }33 data += `],` + newLine;34 }35 data += ` testRunner: "${test.testRunner}",` + newLine;36 data += ` testFramework: "${test.testFramework}",` + newLine;37 data += ` coverageAnalysis: "perTest",` + newLine;38 data += " karma: {" + newLine;39 data += ` configFile: "${test.configFile}"` + newLine;40 data += " }" + newLine;41 data += " });" + newLine;42 data += "};" + newLine;43 44 var rootDir = path.normalize(test.dir);45 var stryker = path.normalize('node_modules/.bin/stryker');46 var cmd = 'npm install --save-dev stryker stryker-api';47 if(test.reporters.includes('html')) cmd += ' stryker-html-reporter';48 if(test.mutator == 'javascript') cmd += ' stryker-javascript-mutator';49 if(test.mutator == 'typescript') cmd += ' stryker-typescript';50 if(test.mutator == 'vue') cmd += ' stryker-vue-mutator';51 if(test.testRunner == 'karma') cmd += ' stryker-karma-runner';52 if(test.testRunner == 'jest') cmd += ' stryker-jest-runner';53 if(test.testRunner == 'mocha') cmd += ' stryker-mocha-runner';54 if(test.testRunner == 'jasmine') cmd += ' stryker-jasmine-runner';55 if(test.testFramework == 'mocha') cmd += ' stryker-mocha-framework';56 if(test.testFramework == 'jasmine') cmd += ' stryker-jasmine';57 if (!shell.test('-e', path.normalize(`${rootDir}/${stryker}`))) {58 shell.exec(cmd, {cwd: rootDir});59 }60 fs.writeFileSync(`${rootDir}/stryker.conf.js`, data);61};62public.runTests = function(test) {63 var rootDir = path.normalize(test.dir);64 var stryker = path.normalize('node_modules/.bin/stryker');65 shell.exec(`${stryker} run`, {cwd: rootDir});66 shell.exec('reports/mutation/html/index.html', {cwd: rootDir});67};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const stryker = require('stryker-parent');2const stryker = require('stryker-parent');3const stryker = require('stryker-parent');4const stryker = require('stryker-parent');5const stryker = require('stryker-parent');6const stryker = require('stryker-parent');7const stryker = require('stryker-parent');8const stryker = require('stryker-parent');9const stryker = require('stryker-parent');10const stryker = require('stryker-parent');11const stryker = require('stryker-parent');12const stryker = require('stryker-parent');13const stryker = require('stryker-parent');14const stryker = require('stryker-parent');15const stryker = require('stryker-parent');16const stryker = require('stryker-parent');17const stryker = require('stryker-parent');18const stryker = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent').stryker;2var stryker = require('stryker-parent').stryker;3var stryker = require('stryker-parent').stryker;4var stryker = require('stryker-parent').stryker;5var stryker = require('stryker-parent').stryker;6var stryker = require('stryker-parent').stryker;7var stryker = require('stryker-parent').stryker;8var stryker = require('stryker-parent').stryker;9var stryker = require('stryker-parent').stryker;10var stryker = require('stryker-parent').stryker;11var stryker = require('stryker-parent').stryker;12var stryker = require('stryker-parent').stryker;13var stryker = require('stryker-parent').stryker;14var stryker = require('stryker-parent').stryker;15var stryker = require('stryker-parent').stryker;16var stryker = require('stryker-parent').stryker;

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker');2var config = {3 karma: {4 config: {5 }6 }7};8stryker.run(config).then(function (result) {9 console.log('Done!');10 console.log(result);11});12var config = {13 karma: {14 config: {15 }16 }17};18module.exports = config;19var stryker = require('stryker');20var config = {21 karma: {22 config: {23 }24 }25};26stryker.run(config).then(function (result) {27 console.log('Done!');28 console.log(result);29});30var config = {31 karma: {32 config: {33 }34 }35};36module.exports = config;

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function(stryker) {2 stryker.set({3 });4};5module.exports = function(stryker) {6 stryker.set({7 });8};9module.exports = function(stryker) {10 stryker.set({11 });12};13module.exports = function(stryker) {14 stryker.set({15 });16};17module.exports = function(stryker) {18 stryker.set({19 });20};21module.exports = function(stryker) {22 stryker.set({23 });24};25module.exports = function(stryker) {26 stryker.set({27 });28};29module.exports = function(stryker) {30 stryker.set({31 });32};33module.exports = function(stryker) {34 stryker.set({35 });36};37module.exports = function(stryker) {38 stryker.set({39 });40};41module.exports = function(stryker) {42 stryker.set({43 });44};

Full Screen

Using AI Code Generation

copy

Full Screen

1const stryker = require('stryker');2const strykerParent = require('stryker-parent');3const stryker = require('stryker');4const strykerParent = require('stryker-parent');5const stryker = require('stryker');6const strykerParent = require('stryker-parent');7const stryker = require('stryker');8const strykerParent = require('stryker-parent');9const stryker = require('stryker');10const strykerParent = require('stryker-parent');11const stryker = require('stryker');12const strykerParent = require('stryker-parent');13const stryker = require('stryker');14const strykerParent = require('stryker-parent');15const stryker = require('stryker');16const strykerParent = require('stryker-parent');17const stryker = require('stryker');18const strykerParent = require('stryker-parent');

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