How to use strykerKarmaConfigPath method in stryker-parent

Best JavaScript code snippet using stryker-parent

angular-starter.ts

Source:angular-starter.ts Github

copy

Full Screen

1import decamelize from 'decamelize';2import { Logger } from '@stryker-mutator/api/logging';3import semver from 'semver';4import type { requireResolve } from '@stryker-mutator/util';5import { StrykerOptions } from '@stryker-mutator/api/core';6import { commonTokens, tokens } from '@stryker-mutator/api/plugin';7import { NgTestArguments } from '../../src-generated/karma-runner-options.js';8import { strykerKarmaConfigPath } from '../karma-plugins/index.js';9import { KarmaRunnerOptionsWithStrykerOptions } from '../karma-runner-options-with-stryker-options.js';10import { pluginTokens } from '../plugin-tokens.js';11import { StartedProject } from './started-project.js';12import { ProjectStarter } from './project-starter.js';13const MIN_ANGULAR_CLI_VERSION = '6.1.0';14type AngularCli = (options: { testing?: boolean; cliArgs: string[] }) => Promise<number>;15export class AngularProjectStarter implements ProjectStarter {16 public static inject = tokens(commonTokens.logger, commonTokens.options, pluginTokens.requireResolve);17 constructor(private readonly logger: Logger, private readonly options: StrykerOptions, private readonly requireFromCwd: typeof requireResolve) {}18 public async start(): Promise<StartedProject> {19 this.verifyAngularCliVersion();20 const ngConfig = (this.options as KarmaRunnerOptionsWithStrykerOptions).karma.ngConfig;21 // Make sure require angular cli from inside this function, that way it won't break if angular isn't installed and this file is required.22 let cli = this.requireFromCwd('@angular/cli') as AngularCli;23 if ('default' in cli) {24 cli = (cli as unknown as { default: AngularCli }).default;25 }26 const cliArgs = ['test', '--progress=false', `--karma-config=${strykerKarmaConfigPath}`];27 if (ngConfig?.testArguments) {28 const testArguments: NgTestArguments = ngConfig.testArguments;29 const ngTestArguments = Object.keys(testArguments);30 verifyNgTestArguments(ngTestArguments);31 ngTestArguments.forEach((key) => {32 const decamelizedKey = decamelize(key, { separator: '-' });33 if ('progress' !== key && 'karma-config' !== decamelizedKey) {34 cliArgs.push(`--${decamelizedKey}=${testArguments[key]}`);35 }36 });37 }38 const actualCommand = `ng ${cliArgs.join(' ')}`;39 this.logger.debug(`Starting Angular tests: ${actualCommand}`);40 return {41 exitPromise: cli({ cliArgs }),42 };43 }44 private verifyAngularCliVersion() {45 const pkg = this.requireFromCwd('@angular/cli/package') as { version: string };46 const version = semver.coerce(pkg.version);47 if (!version || semver.lt(version, MIN_ANGULAR_CLI_VERSION)) {48 throw new Error(`Your @angular/cli version (${version}) is not supported. Please install ${MIN_ANGULAR_CLI_VERSION} or higher`);49 }50 }51}52function verifyNgTestArguments(ngTestArguments: string[]) {53 const prefixedArguments = ngTestArguments.filter((key) => key.trim().startsWith('-'));54 if (prefixedArguments.length > 0) {55 throw new Error(`Don't prefix arguments with dashes ('-'). Stryker will do this automatically. Problematic arguments are ${prefixedArguments}.`);56 }...

Full Screen

Full Screen

angular-starter.spec.ts

Source:angular-starter.spec.ts Github

copy

Full Screen

1import { testInjector } from '@stryker-mutator/test-helpers';2import type { requireResolve } from '@stryker-mutator/util';3import { expect } from 'chai';4import sinon from 'sinon';5import { strykerKarmaConfigPath } from '../../../src/karma-plugins/stryker-karma.conf.js';6import { KarmaRunnerOptionsWithStrykerOptions } from '../../../src/karma-runner-options-with-stryker-options.js';7import { pluginTokens } from '../../../src/plugin-tokens.js';8import { AngularProjectStarter } from '../../../src/starters/angular-starter.js';9describe('angularStarter', () => {10 let requireResolveStub: sinon.SinonStubbedMember<typeof requireResolve>;11 let cliStub: sinon.SinonStub;12 let sut: AngularProjectStarter;13 let options: KarmaRunnerOptionsWithStrykerOptions;14 beforeEach(() => {15 cliStub = sinon.stub();16 requireResolveStub = sinon.stub();17 requireResolveStub.withArgs('@angular/cli').returns(cliStub);18 sut = testInjector.injector.provideValue(pluginTokens.requireResolve, requireResolveStub).injectClass(AngularProjectStarter);19 options = testInjector.options as KarmaRunnerOptionsWithStrykerOptions;20 options.karma = { projectType: 'angular-cli' };21 });22 it('should throw an error if angular cli version < 6.1.0', async () => {23 setAngularVersion('6.0.8');24 await expect(sut.start()).rejectedWith('Your @angular/cli version (6.0.8) is not supported. Please install 6.1.0 or higher');25 });26 it('should support version 6.1.0 and up inc release candidates', async () => {27 cliStub.resolves();28 requireResolveStub29 .withArgs('@angular/cli/package')30 .onFirstCall()31 .returns({ version: '6.1.0-rc.0' })32 .onSecondCall()33 .returns({ version: '6.2.0' })34 .onThirdCall()35 .returns({ version: '6.2.0-rc.0' });36 await expect(sut.start()).not.rejected;37 await expect(sut.start()).not.rejected;38 await expect(sut.start()).not.rejected;39 });40 it('should execute the cli', async () => {41 cliStub.resolves();42 setAngularVersion();43 await sut.start();44 expect(cliStub).calledWith({45 cliArgs: ['test', '--progress=false', `--karma-config=${strykerKarmaConfigPath}`],46 });47 });48 it('should forward ngOptions', async () => {49 options.karma.ngConfig = {50 testArguments: {51 baz: 'true',52 foo: 'bar',53 fooBar: 'baz',54 },55 };56 setAngularVersion();57 cliStub.resolves();58 await sut.start();59 expect(cliStub).calledWith({60 cliArgs: ['test', '--progress=false', `--karma-config=${strykerKarmaConfigPath}`, '--baz=true', '--foo=bar', '--foo-bar=baz'],61 });62 });63 it('should reject when ngOptions are prefixed', async () => {64 options.karma.ngConfig = {65 testArguments: {66 '--project': '@ns/myproj',67 },68 };69 setAngularVersion();70 return expect(sut.start()).rejectedWith(71 "Don't prefix arguments with dashes ('-'). Stryker will do this automatically. Problematic arguments are --project"72 );73 });74 function setAngularVersion(version = '100') {75 requireResolveStub.withArgs('@angular/cli/package').returns({ version });76 }...

Full Screen

Full Screen

karma-starter.ts

Source:karma-starter.ts Github

copy

Full Screen

1import { Task } from '@stryker-mutator/util';2import type { Config, ConfigOptions } from 'karma';3import { strykerKarmaConfigPath } from '../karma-plugins/index.js';4import { karma } from '../karma-wrapper.js';5import type { ProjectStarter } from './project-starter.js';6import type { StartedProject } from './started-project.js';7export const karmaConfigStarter: ProjectStarter = {8 async start(): Promise<StartedProject> {9 const configFile = strykerKarmaConfigPath;10 let config: Config | ConfigOptions = {11 configFile,12 };13 if (karma.config?.parseConfig) {14 config = await karma.config.parseConfig(configFile, {}, { promiseConfig: true, throwErrors: true });15 }16 const exitTask = new Task<number>();17 await new karma.Server(config, exitTask.resolve).start();18 return {19 exitPromise: exitTask.promise,20 };21 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2module.exports = function (config) {3 config.set({4 { pattern: strykerKarmaConfigPath('test.js'), mutated: true, included: false },5 { pattern: 'src/**/*.js', mutated: true, included: false },6 { pattern: 'test/**/*.js', mutated: false, included: false }7 });8};9module.exports = function (config) {10 config.set({11 karma: {12 },13 });14};15{16 "scripts": {17 },18 "devDependencies": {19 },20 "dependencies": {21 }22}

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2module.exports = function(config) {3 config.set({4 preprocessors: {5 },6 babelPreprocessor: {7 options: {8 }9 },10 coverageReporter: {11 { type: 'html', dir: 'coverage/' },12 { type: 'text-summary' }13 },14 karmaConfig: strykerKarmaConfigPath(__dirname)15 });16};

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2var path = require('path');3module.exports = function(config) {4 config.set({5 {pattern: 'src/**/*.js', mutated: true, included: false},6 preprocessors: {7 },8 coverageReporter: {9 {type: 'html', subdir: 'html'}10 },11 htmlReporter: {12 },13 karmaConfigFile: strykerKarmaConfigPath(path.resolve(__dirname, 'karma.conf.js'))14 });15};16module.exports = function(config) {17 config.set({18 {pattern: 'src/**/*.js', mutated: true, included: false},19 preprocessors: {20 },21 coverageReporter: {22 {type: 'html', subdir: 'html'}23 },24 htmlReporter: {25 },26 });27};

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2module.exports = function(config) {3 config.set({4 preprocessors: {5 },6 karmaTypescriptConfig: {7 bundlerOptions: {8 transforms: [require('karma-typescript-es6-transform')()]9 }10 },11 webpack: require(strykerKarmaConfigPath('webpack.config.js'))12 });13};14module.exports = {15 resolve: {16 },17 module: {18 {19 }20 }21};

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2const strykerKarmaConfig = require(strykerKarmaConfigPath('test'));3module.exports = strykerKarmaConfig;4const strykerKarmaConfig = require('./test');5module.exports = function (config) {6 config.set(strykerKarmaConfig);7};8module.exports = function (config) {9 config.set({10 karma: {11 }12 });13};14module.exports = function (config) {15 config.set({16 karma: {17 }18 });19};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { strykerKarmaConfigPath } = require('@alfresco/adf-testing');2module.exports = function(config) {3 config.set({4 require('karma-jasmine'),5 require('karma-chrome-launcher'),6 require('karma-coverage-istanbul-reporter'),7 require('karma-jasmine-html-reporter'),8 require('karma-coverage'),9 require('karma-spec-reporter'),10 require('karma-junit-reporter'),11 require('@angular-devkit/build-angular/plugins/karma')12 client: {13 },14 coverageIstanbulReporter: {15 },16 angularCli: {17 },18 junitReporter: {19 },20 {21 pattern: strykerKarmaConfigPath('node_modules/@alfresco/adf-testing/lib/browser.js'),22 }23 });24};25const { strykerKarmaConfig } = require('@alfresco/adf-testing');26module.exports = function(config) {27 config.set(28 strykerKarmaConfig({29 require('karma-jasmine'),30 require('karma-chrome-launcher'),31 require('karma-coverage-istanbul-reporter'),32 require('karma-jasmine-html-reporter'),33 require('karma-coverage'),34 require('karma-spec-reporter'),35 require('karma-junit-reporter'),36 require('@angular-devkit/build-angular/plugins/karma')37 client: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2module.exports = function(config) {3 config.set({4 files: strykerKarmaConfigPath()5 });6};7module.exports = function(config) {8 config.set({9 files: require('stryker-parent').strykerKarmaConfigPath()10 });11};

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerKarmaConfigPath = require('stryker-parent').strykerKarmaConfigPath;2console.log(strykerKarmaConfigPath());3module.exports = function (config) {4 config.set({5 karma: {6 configFile: require('stryker-parent').strykerKarmaConfigPath()7 },8 });9};10const Stryker = require('stryker-api/core').default;11const config = require('./stryker.conf');12const stryker = new Stryker(config);13stryker.runMutationTest();

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