How to use actualFailedTests method in stryker-parent

Best JavaScript code snippet using stryker-parent

karma-test-runner.it.spec.ts

Source:karma-test-runner.it.spec.ts Github

copy

Full Screen

1import { promisify } from 'util';2import http from 'http';3import { TestStatus, CompleteDryRunResult, TestResult, FailedTestResult } from '@stryker-mutator/api/test-runner';4import { testInjector, assertions, factory } from '@stryker-mutator/test-helpers';5import { expect } from 'chai';6import { FilePattern } from 'karma';7import { KarmaTestRunner } from '../../src/karma-test-runner';8import { StrykerReporter } from '../../src/karma-plugins/stryker-reporter';9import { KarmaRunnerOptionsWithStrykerOptions } from '../../src/karma-runner-options-with-stryker-options';10function setOptions({11 files = ['testResources/sampleProject/src-instrumented/Add.js', 'testResources/sampleProject/test-jasmine/AddSpec.js'],12 frameworks = ['jasmine'],13}: {14 files?: ReadonlyArray<FilePattern | string>;15 frameworks?: string[];16}): void {17 (testInjector.options as KarmaRunnerOptionsWithStrykerOptions).karma = {18 projectType: 'custom',19 config: {20 files,21 logLevel: 'off',22 reporters: [],23 frameworks,24 },25 };26}27function createSut() {28 return testInjector.injector.injectClass(KarmaTestRunner);29}30describe(`${KarmaTestRunner.name} integration`, () => {31 let sut: KarmaTestRunner;32 const expectToHaveSuccessfulTests = (result: CompleteDryRunResult, n: number) => {33 expect(result.tests.filter((t) => t.status === TestStatus.Success)).to.have.length(n);34 };35 const expectToHaveFailedTests = (result: CompleteDryRunResult, expectedFailureMessages: string[]) => {36 const actualFailedTests = result.tests.filter(isFailed);37 expect(actualFailedTests).to.have.length(expectedFailureMessages.length);38 actualFailedTests.forEach((failedTest) => {39 const actualFailedMessage = failedTest.failureMessage.split('\n')[0];40 expect(actualFailedMessage).to.be.oneOf(expectedFailureMessages);41 });42 };43 describe('when all tests succeed', () => {44 before(() => {45 setOptions({ files: ['testResources/sampleProject/src/Add.js', 'testResources/sampleProject/test-jasmine/AddSpec.js'] });46 sut = createSut();47 return sut.init();48 });49 after(async () => {50 await sut.dispose();51 });52 describe('dryRun()', () => {53 it('should report completed tests', async () => {54 const runResult = await sut.dryRun(factory.dryRunOptions());55 assertions.expectCompleted(runResult);56 expectToHaveSuccessfulTests(runResult, 5);57 expectToHaveFailedTests(runResult, []);58 });59 it('should be able to run twice in quick succession', async () => {60 const actualResult = await sut.dryRun(factory.dryRunOptions());61 assertions.expectCompleted(actualResult);62 });63 });64 describe('runMutant()', () => {65 it('should report the mutant as survived', async () => {66 const mutantResult = await sut.mutantRun(factory.mutantRunOptions());67 assertions.expectSurvived(mutantResult);68 });69 });70 });71 describe('when some tests fail', () => {72 beforeEach(() => {73 setOptions({74 files: [75 'testResources/sampleProject/src/Add.js',76 'testResources/sampleProject/test-jasmine/AddSpec.js',77 'testResources/sampleProject/test-jasmine/AddFailedSpec.js',78 ],79 });80 });81 afterEach(async () => {82 await sut.dispose();83 });84 describe('dryRun', () => {85 it('should report the first failed test (bail)', async () => {86 // Arrange87 sut = createSut();88 await sut.init();89 // Act90 const runResult = await sut.dryRun(factory.dryRunOptions());91 // Assert92 assertions.expectCompleted(runResult);93 expectToHaveSuccessfulTests(runResult, 5);94 expectToHaveFailedTests(runResult, ['Error: Expected 7 to be 8.']);95 });96 it('should report all failing tests when disableBail is true', async () => {97 // Arrange98 testInjector.options.disableBail = true;99 sut = createSut();100 await sut.init();101 // Act102 const runResult = await sut.dryRun(factory.dryRunOptions());103 // Assert104 assertions.expectCompleted(runResult);105 expectToHaveSuccessfulTests(runResult, 5);106 expectToHaveFailedTests(runResult, ['Error: Expected 7 to be 8.', 'Error: Expected 3 to be 4.']);107 });108 });109 describe('runMutant()', () => {110 it('should report the mutant as killed', async () => {111 // Arrange112 sut = createSut();113 await sut.init();114 // Act115 const mutantResult = await sut.mutantRun(factory.mutantRunOptions());116 // Assert117 assertions.expectKilled(mutantResult);118 expect(mutantResult.killedBy).deep.eq(['spec5']);119 expect(mutantResult.failureMessage.split('\n')[0]).eq('Error: Expected 7 to be 8.');120 });121 it('should report all failed tests when disableBail is true', async () => {122 // Arrange123 testInjector.options.disableBail = true;124 sut = createSut();125 await sut.init();126 // Act127 const mutantResult = await sut.mutantRun(factory.mutantRunOptions());128 // Assert129 assertions.expectKilled(mutantResult);130 expect(mutantResult.killedBy).deep.eq(['spec5', 'spec6']);131 expect(mutantResult.failureMessage.split('\n')[0]).eq('Error: Expected 7 to be 8.');132 });133 });134 });135 describe('when an error occurs while running tests', () => {136 before(() => {137 setOptions({138 files: [139 'testResources/sampleProject/src/Add.js',140 'testResources/sampleProject/src/Error.js',141 'testResources/sampleProject/test-jasmine/AddSpec.js',142 ],143 });144 sut = createSut();145 return sut.init();146 });147 after(async () => {148 await sut.dispose();149 });150 describe('dryRun', () => {151 it('should report Error with the error message', async () => {152 const runResult = await sut.dryRun(factory.dryRunOptions());153 assertions.expectErrored(runResult);154 expect(runResult.errorMessage).include('ReferenceError: someGlobalVariableThatIsNotDeclared is not defined');155 });156 });157 describe('runMutant()', () => {158 it('should report Error with the error message', async () => {159 const runResult = await sut.mutantRun(factory.mutantRunOptions());160 assertions.expectErrored(runResult);161 expect(runResult.errorMessage).include('ReferenceError: someGlobalVariableThatIsNotDeclared is not defined');162 });163 });164 });165 describe('when an error occurs on startup', () => {166 it('should reject the init promise', async () => {167 setOptions({ frameworks: ['jasmine', 'not-exists'] });168 sut = createSut();169 await expect(sut.init()).rejected;170 });171 afterEach(async () => {172 await sut.dispose();173 });174 });175 describe('when no error occurred and no test is performed', () => {176 before(() => {177 setOptions({ files: ['testResources/sampleProject/src/Add.js', 'testResources/sampleProject/test-jasmine/EmptySpec.js'] });178 sut = createSut();179 return sut.init();180 });181 after(async () => {182 await sut.dispose();183 });184 it('should report Complete without errors', async () => {185 const runResult = await sut.dryRun(factory.dryRunOptions());186 assertions.expectCompleted(runResult);187 expectToHaveSuccessfulTests(runResult, 0);188 expectToHaveFailedTests(runResult, []);189 });190 });191 describe('when adding an error file with included: false', () => {192 before(() => {193 setOptions({194 files: [195 { pattern: 'testResources/sampleProject/src/Add.js', included: true },196 { pattern: 'testResources/sampleProject/test-jasmine/AddSpec.js', included: true },197 { pattern: 'testResources/sampleProject/src/Error.js', included: false },198 ],199 });200 sut = createSut();201 return sut.init();202 });203 after(async () => {204 await sut.dispose();205 });206 it('should report Complete without errors', async () => {207 const runResult = await sut.dryRun(factory.dryRunOptions());208 assertions.expectCompleted(runResult);209 });210 });211 describe('when specified port is not available', () => {212 let dummyServer: DummyServer;213 before(async () => {214 dummyServer = await DummyServer.create();215 setOptions({});216 sut = createSut();217 return sut.init();218 });219 after(async () => {220 if (dummyServer) {221 await dummyServer.dispose();222 }223 await sut.dispose();224 });225 it('should choose different port automatically and report Complete without errors', async () => {226 const actualResult = await sut.dryRun(factory.dryRunOptions());227 expect(StrykerReporter.instance.karmaConfig!.port).not.eq(dummyServer.port);228 assertions.expectCompleted(actualResult);229 });230 });231});232class DummyServer {233 private readonly httpServer: http.Server;234 private constructor() {235 this.httpServer = http.createServer();236 }237 public get port() {238 const address = this.httpServer.address();239 if (!address || typeof address === 'string') {240 throw new Error(`Address "${address}" was unexpected: https://nodejs.org/dist/latest-v11.x/docs/api/net.html#net_server_address`);241 } else {242 return address.port;243 }244 }245 public static async create(): Promise<DummyServer> {246 const server = new DummyServer();247 await server.init();248 return server;249 }250 private async init(): Promise<void> {251 const listen: (port: number, host: string) => Promise<void> = promisify(this.httpServer.listen.bind(this.httpServer));252 await listen(0, '0.0.0.0');253 }254 public dispose(): Promise<void> {255 return promisify(this.httpServer.close.bind(this.httpServer))();256 }257}258function isFailed(t: TestResult): t is FailedTestResult {259 return t.status === TestStatus.Failed;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var actualFailedTests = require('stryker-parent').actualFailedTests;2actualFailedTests(['test1', 'test2', 'test3'], function (err, failedTests) {3 console.log('Failed tests: ' + failedTests);4});5var actualFailedTests = require('./actualFailedTests');6module.exports = {7};8module.exports = function (tests, callback) {9 callback(null, actualFailedTests);10};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { actualFailedTests } = require('stryker-parent');2const { StrykerOptions } = require('stryker-api/core');3const { RunResult, TestResult } = require('stryker-api/test_runner');4const { TestStatus } = require('stryker-api/test_framework');5const { actualFailedTests } = require('stryker-parent');6const { StrykerOptions } = require('stryker-api/core');7const { RunResult, TestResult } = require('stryker-api/test_runner');8const { TestStatus } = require('stryker-api/test_framework');9const runResult = new RunResult();10runResult.tests.push(new TestResult({ name: 'test1', status: TestStatus.Success }));11runResult.tests.push(new TestResult({ name: 'test2', status: TestStatus.Failed }));12runResult.tests.push(new TestResult({ name: 'test3', status: TestStatus.Success }));13runResult.tests.push(new TestResult({ name: 'test4', status: TestStatus.Failed }));14runResult.tests.push(new TestResult({ name: 'test5', status: TestStatus.Skipped }));15runResult.tests.push(new TestResult({ name: 'test6', status: TestStatus.Success }));16runResult.tests.push(new TestResult({ name: 'test7', status: TestStatus.Failed }));17runResult.tests.push(new TestResult({ name: 'test8', status: TestStatus.Success }));18runResult.tests.push(new TestResult({ name: 'test9', status: TestStatus.Failed }));19runResult.tests.push(new TestResult({ name: 'test10', status: TestStatus.Success }));20const options = new StrykerOptions();21options.thresholds = { high: 80, low: 60, break: null };22options.timeoutMS = 5000;23const result = actualFailedTests(runResult, options);24console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { actualFailedTests } from 'stryker-parent';2const result = actualFailedTests();3console.log(result);4module.exports = function (config) {5 config.set({6 jest: {7 config: require('./jest.config.js'),8 },9 });10};11module.exports = {12 coverageThreshold: {13 global: {14 }15 }16};17module.exports = {18 add: (a, b) => a + b19};20import { actualFailedTests } from 'stryker-parent';21const result = actualFailedTests();22console.log(result);23module.exports = function (config) {24 config.set({25 jest: {26 config: require('./jest.config.js'),27 },28 });29};30module.exports = {31 coverageThreshold: {32 global: {33 }34 }35};36module.exports = {37 add: (a, b) => a + b38};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var failedTests = stryker.actualFailedTests('test.js');3var stryker = require('stryker-parent');4var failedTests = stryker.actualFailedTests('test.js');5var stryker = require('stryker-parent');6var failedTests = stryker.actualFailedTests('test.js');7var stryker = require('stryker-parent');8var failedTests = stryker.actualFailedTests('test.js');9var stryker = require('stryker-parent');10var failedTests = stryker.actualFailedTests('test.js');11var stryker = require('stryker-parent');12var failedTests = stryker.actualFailedTests('test.js');13var stryker = require('stryker-parent');14var failedTests = stryker.actualFailedTests('test.js');15var stryker = require('stryker-parent');16var failedTests = stryker.actualFailedTests('test.js');17var stryker = require('stryker-parent');18var failedTests = stryker.actualFailedTests('test.js');19var stryker = require('stryker-parent');20var failedTests = stryker.actualFailedTests('test.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1let stryker = require('stryker-parent');2let actualFailedTests = stryker.actualFailedTests;3let failedTests = actualFailedTests();4console.log('failedTests: ', failedTests);5let stryker = require('stryker-parent');6let actualFailedTests = stryker.actualFailedTests;7module.exports = function(config) {8 config.set({9 mochaOptions: {10 },11 sandbox: {12 fileHeaders: {},13 },14 thresholds: {15 },16 });17};

Full Screen

Using AI Code Generation

copy

Full Screen

1const actualFailedTests = require('stryker-parent').actualFailedTests;2const actualFailedTests = require('stryker-parent').actualFailedTests;3const actualFailedTests = require('stryker-parent').actualFailedTests;4const actualFailedTests = require('stryker-parent').actualFailedTests;5const actualFailedTests = require('stryker-parent').actualFailedTests;6const actualFailedTests = require('stryker-parent').actualFailedTests;7const actualFailedTests = require('stryker-parent').actualFailedTests;8const actualFailedTests = require('stryker-parent').actualFailedTests;9const actualFailedTests = require('stryker-parent').actualFailedTests;10const actualFailedTests = require('stry

Full Screen

Using AI Code Generation

copy

Full Screen

1const { actualFailedTests } = require('stryker-parent');2const testResult = actualFailedTests();3console.log(testResult);4const { actualFailedTests } = require('stryker-parent');5const testResult = actualFailedTests();6console.log(testResult);7const { actualFailedTests } = require('stryker-parent');8const testResult = actualFailedTests();9console.log(testResult);10const { actualFailedTests } = require('stryker-parent');11const testResult = actualFailedTests();12console.log(testResult);13const { actualFailedTests } = require('stryker-parent');14const testResult = actualFailedTests();15console.log(testResult);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { actualFailedTests } = require('stryker-parent');2const { run } = require('stryker');3const failedTests = actualFailedTests();4console.log(failedTests);5run({6 mochaOptions: {7 }8}).then((result) => {9 console.log('Stryker has completed the test run');10 console.log(`Your mutation score is: ${result.score}`);11}, (error) => {12 console.error('Stryker has failed the test run', error);13});14run({15 mochaOptions: {16 }17}).then((result) => {18 console.log('Stryker has completed the test run');19 console.log(`Your mutation score is: ${result.score}`);20}, (error) => {21 console.error('Stryker has failed the test run', error);22});23run({24 mochaOptions: {25 }26}).then((result) => {27 console.log('Stryker has completed the test run');28 console.log(`Your mutation score is: ${result.score}`);29}, (error) => {30 console.error('Stryker has failed the test run', error);31});32run({33 mochaOptions: {34 }35}).then((result) => {36 console.log('Stryker has completed the test run');37 console.log(`Your mutation score is: ${result.score}`);38}, (error) => {39 console.error('Stryker has failed the test run', error);40});

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