How to use restoreTTY method in stryker-parent

Best JavaScript code snippet using stryker-parent

broadcast-reporter.spec.ts

Source:broadcast-reporter.spec.ts Github

copy

Full Screen

...20 pluginCreatorMock = sinon.createStubInstance(PluginCreator);21 pluginCreatorMock.create.withArgs('rep1').returns(rep1).withArgs('rep2').returns(rep2);22 });23 afterEach(() => {24 restoreTTY();25 });26 describe('when constructed', () => {27 it('should create "progress-append-only" instead of "progress" reporter if process.stdout is not a tty', () => {28 // Arrange29 setTTY(false);30 const expectedReporter = factory.reporter('progress-append-only');31 testInjector.options.reporters = ['progress'];32 pluginCreatorMock.create.returns(expectedReporter);33 // Act34 sut = createSut();35 // Assert36 expect(sut.reporters).deep.eq({ 'progress-append-only': expectedReporter });37 expect(pluginCreatorMock.create).calledWith('progress-append-only');38 });39 it('should create the correct reporters', () => {40 // Arrange41 setTTY(true);42 testInjector.options.reporters = ['progress', 'rep2'];43 const progress = factory.reporter('progress');44 pluginCreatorMock.create.withArgs('progress').returns(progress);45 // Act46 sut = createSut();47 // Assert48 expect(sut.reporters).deep.eq({49 progress,50 rep2,51 });52 });53 it('should warn if there is no reporter', () => {54 testInjector.options.reporters = [];55 sut = createSut();56 expect(testInjector.logger.warn).calledWith(sinon.match('No reporter configured'));57 });58 });59 describe('with 2 reporters', () => {60 beforeEach(() => {61 sut = createSut();62 });63 it('should forward "onSourceFileRead"', () => {64 actAssertShouldForward('onSourceFileRead', factory.sourceFile());65 });66 it('should forward "onAllSourceFilesRead"', () => {67 actAssertShouldForward('onAllSourceFilesRead', [factory.sourceFile()]);68 });69 it('should forward "onAllMutantsMatchedWithTests"', () => {70 actAssertShouldForward('onAllMutantsMatchedWithTests', [factory.mutantTestCoverage()]);71 });72 it('should forward "onMutantTested"', () => {73 actAssertShouldForward('onMutantTested', factory.mutantResult());74 });75 it('should forward "onAllMutantsTested"', () => {76 actAssertShouldForward('onAllMutantsTested', [factory.mutantResult()]);77 });78 it('should forward "onMutationTestReportReady"', () => {79 actAssertShouldForward('onMutationTestReportReady', factory.mutationTestReportSchemaMutationTestResult(), factory.mutationTestMetricsResult());80 });81 it('should forward "wrapUp"', () => {82 actAssertShouldForward('wrapUp');83 });84 describe('when "wrapUp" returns promises', () => {85 let wrapUpResolveFn: (value?: PromiseLike<void> | void) => void;86 let wrapUpResolveFn2: (value?: PromiseLike<void> | void) => void;87 let wrapUpRejectFn: (reason?: any) => void;88 let result: Promise<void>;89 let isResolved: boolean;90 beforeEach(() => {91 isResolved = false;92 rep1.wrapUp.returns(93 new Promise<void>((resolve, reject) => {94 wrapUpResolveFn = resolve;95 wrapUpRejectFn = reject;96 })97 );98 rep2.wrapUp.returns(new Promise<void>((resolve) => (wrapUpResolveFn2 = resolve)));99 result = sut.wrapUp().then(() => void (isResolved = true));100 });101 it('should forward a combined promise', () => {102 expect(isResolved).to.be.eq(false);103 wrapUpResolveFn();104 wrapUpResolveFn2();105 return result;106 });107 describe('and one of the promises results in a rejection', () => {108 let actualError: Error;109 beforeEach(() => {110 actualError = new Error('some error');111 wrapUpRejectFn(actualError);112 wrapUpResolveFn2();113 return result;114 });115 it('should not result in a rejection', () => result);116 it('should log the error', () => {117 expect(testInjector.logger.error).calledWith("An error occurred during 'wrapUp' on reporter 'rep1'.", actualError);118 });119 });120 });121 describe('with one faulty reporter', () => {122 let actualError: Error;123 beforeEach(() => {124 actualError = new Error('some error');125 factory.ALL_REPORTER_EVENTS.forEach((eventName) => rep1[eventName].throws(actualError));126 });127 it('should still broadcast "onSourceFileRead"', () => {128 actAssertShouldForward('onSourceFileRead', factory.sourceFile());129 });130 it('should still broadcast "onAllSourceFilesRead"', () => {131 actAssertShouldForward('onAllSourceFilesRead', [factory.sourceFile()]);132 });133 it('should still broadcast "onAllMutantsMatchedWithTests"', () => {134 actAssertShouldForward('onAllMutantsMatchedWithTests', [factory.mutantTestCoverage()]);135 });136 it('should still broadcast "onMutantTested"', () => {137 actAssertShouldForward('onMutantTested', factory.mutantResult());138 });139 it('should still broadcast "onAllMutantsTested"', () => {140 actAssertShouldForward('onAllMutantsTested', [factory.mutantResult()]);141 });142 it('should still broadcast "onMutationTestReportReady"', () => {143 actAssertShouldForward(144 'onMutationTestReportReady',145 factory.mutationTestReportSchemaMutationTestResult(),146 factory.mutationTestMetricsResult()147 );148 });149 it('should still broadcast "wrapUp"', () => {150 actAssertShouldForward('wrapUp');151 });152 it('should log each error', () => {153 factory.ALL_REPORTER_EVENTS.forEach((eventName) => {154 (sut as any)[eventName]();155 expect(testInjector.logger.error).to.have.been.calledWith(`An error occurred during '${eventName}' on reporter 'rep1'.`, actualError);156 });157 });158 });159 });160 function createSut() {161 return testInjector.injector162 .provideValue(coreTokens.pluginCreatorReporter, pluginCreatorMock as unknown as PluginCreator<PluginKind.Reporter>)163 .injectClass(BroadcastReporter);164 }165 function captureTTY() {166 isTTY = process.stdout.isTTY;167 }168 function restoreTTY() {169 process.stdout.isTTY = isTTY;170 }171 function setTTY(val: boolean) {172 process.stdout.isTTY = val;173 }174 function actAssertShouldForward<TMethod extends keyof Reporter>(method: TMethod, ...input: Parameters<Required<Reporter>[TMethod]>) {175 (sut[method] as (...args: Parameters<Required<Reporter>[TMethod]>) => Promise<void> | void)(...input);176 expect(rep1[method]).calledWithExactly(...input);177 expect(rep2[method]).calledWithExactly(...input);178 }...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1'use strict';2require('mocha');3var isCI = process.env.TRAVIS || process.env.APPVEYOR || process.env.CI;4var assert = require('assert');5var utils = require('./utils');6var size = require('./');7var tty = require('tty');8function override(obj) {9 var getWindowSize = obj.getWindowSize;10 var columns = obj.columns;11 var rows = obj.rows;12 obj.getWindowSize = null;13 obj.columns = null;14 obj.rows = null;15 return function() {16 obj.getWindowSize = getWindowSize;17 obj.columns = columns;18 obj.rows = rows;19 };20}21describe('window-size', function() {22 it('should return an object with width and height', function() {23 if (!process.env.APPVEYOR) {24 assert.equal(typeof size.width, 'number');25 assert.equal(typeof size.height, 'number');26 }27 });28 it('should expose a `.get` method to get up-to-date size', function() {29 if (!process.env.APPVEYOR) {30 var s = size.get();31 assert.equal(typeof s.width, 'number');32 assert.equal(typeof s.height, 'number');33 }34 });35 it('should get size from process.stdout', function() {36 if (!process.env.APPVEYOR) {37 var count = 0;38 var restore = override(process.stdout);39 process.stdout.getWindowSize = function() {40 count++;41 };42 size.get();43 restore();44 assert.equal(count, 1);45 }46 });47 it('should get size from process.stderr', function() {48 if (!process.env.APPVEYOR) {49 var restoreOut = override(process.stdout);50 var restoreErr = override(process.stderr);51 var count = 0;52 process.stderr.getWindowSize = function() {53 count++;54 };55 size.get();56 restoreOut();57 restoreErr();58 assert.equal(count, 1);59 }60 });61 it('should get size from process.env', function() {62 if (!process.env.APPVEYOR) {63 process.env.COLUMNS = 80;64 process.env.ROWS = 25;65 var s = size.env();66 assert(s);67 assert.equal(s.width, 80);68 assert.equal(s.height, 25);69 process.env.COLUMNS = null;70 process.env.ROWS = null;71 }72 });73 it('should get size from tty', function() {74 if (!process.env.APPVEYOR) {75 var restoreOut = override(process.stdout);76 var restoreErr = override(process.stderr);77 var restoreTty = override(tty);78 var count = 0;79 tty.getWindowSize = function() {80 count++;81 };82 size.get();83 restoreOut();84 restoreErr();85 restoreTty();86 assert.equal(count, 1);87 }88 });89 it('should get size from tput', function() {90 if (!isCI) {91 var s = size.tput();92 assert(s);93 assert.equal(typeof s.width, 'number');94 assert.equal(typeof s.height, 'number');95 }96 });97 describe('utils', function() {98 it('should expose a `.get` method to get up-to-date size', function() {99 var s = utils.get();100 if (process.env.APPVEYOR) {101 assert.equal(typeof s, 'undefined');102 } else {103 assert.equal(typeof s.width, 'number');104 assert.equal(typeof s.height, 'number');105 }106 });107 it('should get size from process.env', function() {108 process.env.COLUMNS = 80;109 process.env.ROWS = 25;110 var s = utils.env();111 assert(s);112 assert.equal(s.width, 80);113 assert.equal(s.height, 25);114 process.env.COLUMNS = null;115 process.env.ROWS = null;116 });117 it('should get size from tty', function() {118 var restoreTty = override(tty);119 var count = 0;120 tty.getWindowSize = function() {121 count++;122 };123 utils.tty({});124 restoreTty();125 assert.equal(count, 1);126 });127 it('should get size from tput', function() {128 if (!isCI) {129 var s = utils.tput();130 assert(s);131 assert.equal(typeof s.width, 'number');132 assert.equal(typeof s.height, 'number');133 }134 });135 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var restoreTTY = require('stryker-parent').restoreTTY;2restoreTTY();3var restoreTTY = require('stryker').restoreTTY;4restoreTTY();5var restoreTTY = require('stryker-api').restoreTTY;6restoreTTY();7var restoreTTY = require('stryker-api/core').restoreTTY;8restoreTTY();9var restoreTTY = require('stryker-api/report').restoreTTY;10restoreTTY();11var restoreTTY = require('stryker-api/test_runner').restoreTTY;12restoreTTY();13var restoreTTY = require('stryker-api/transpiler').restoreTTY;14restoreTTY();15var restoreTTY = require('stryker-mocha-runner').restoreTTY;16restoreTTY();17var restoreTTY = require('stryker-mocha-runner/src').restoreTTY;18restoreTTY();19var restoreTTY = require('stryker-mocha-runner/src/MochaTestRunner').restoreTTY;20restoreTTY();21var restoreTTY = require('stryker-mocha-runner/src/mocha-plugins').restoreTTY;22restoreTTY();23var restoreTTY = require('stryker-mocha-runner/src/mocha-plugins/sandboxed-module').restoreTTY;24restoreTTY();25var restoreTTY = require('stryker-mocha-runner/src/mocha-plugins/sandboxed-module/src').restoreTTY;26restoreTTY();

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var restoreTTY = strykerParent.restoreTTY;3restoreTTY();4var strykerParent = require('stryker-parent');5var restoreTTY = strykerParent.restoreTTY;6restoreTTY();7var strykerParent = require('stryker-parent');8var restoreTTY = strykerParent.restoreTTY;9restoreTTY();10var strykerParent = require('stryker-parent');11var restoreTTY = strykerParent.restoreTTY;12restoreTTY();13var strykerParent = require('stryker-parent');14var restoreTTY = strykerParent.restoreTTY;15restoreTTY();16var strykerParent = require('stryker-parent');17var restoreTTY = strykerParent.restoreTTY;18restoreTTY();19var strykerParent = require('stryker-parent');20var restoreTTY = strykerParent.restoreTTY;21restoreTTY();22var strykerParent = require('stryker-parent');23var restoreTTY = strykerParent.restoreTTY;24restoreTTY();25var strykerParent = require('stryker-parent');26var restoreTTY = strykerParent.restoreTTY;27restoreTTY();28var strykerParent = require('stryker-parent');29var restoreTTY = strykerParent.restoreTTY;30restoreTTY();31var strykerParent = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { restoreTTY } = require('stryker-parent');2if (process.stdin.isTTY) {3 console.log('stdin is TTY');4} else {5 console.log('stdin is not TTY');6}7restoreTTY();8if (process.stdin.isTTY) {9 console.log('stdin is TTY');10} else {11 console.log('stdin is not TTY');12}13module.exports = function(config) {14 config.set({15 commandRunner: {16 }17 });18};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var restore = stryker.restoreTTY;3restore();4var stryker = require('stryker-parent');5var restore = stryker.restoreTTY();6restore();7var stryker = require('stryker-parent');8var ProgressBar = stryker.ProgressBar;9var progressBar = new ProgressBar();

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