From 1fde5a7603dfa1145a738683d02a06c3aeee9326 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Wed, 7 Sep 2022 23:16:54 -0400 Subject: [PATCH] fix tests --- packages/server/test/unit/config_spec.js | 2 ++ packages/server/test/unit/util/trash_spec.js | 10 ++++++++-- packages/server/test/unit/util/tty_spec.js | 18 ------------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/packages/server/test/unit/config_spec.js b/packages/server/test/unit/config_spec.js index 4cdf35762f80..dec04747a408 100644 --- a/packages/server/test/unit/config_spec.js +++ b/packages/server/test/unit/config_spec.js @@ -5,6 +5,7 @@ const stripAnsi = require('strip-ansi') const { stripIndent } = require('common-tags') const Fixtures = require('@tooling/system-tests') const { getCtx } = require('@packages/data-context') +const { sinon } = require('../spec_helper') describe('lib/config', () => { before(function () { @@ -25,6 +26,7 @@ describe('lib/config', () => { this.projectRoot = '/_test-output/path/to/project' + sinon.stub(process, 'chdir').returns() sinon.stub(this.ctx.lifecycleManager, 'verifyProjectRoot').returns(undefined) await this.ctx.lifecycleManager.setCurrentProject(this.projectRoot) diff --git a/packages/server/test/unit/util/trash_spec.js b/packages/server/test/unit/util/trash_spec.js index b09222de3b91..6f792e488a1b 100644 --- a/packages/server/test/unit/util/trash_spec.js +++ b/packages/server/test/unit/util/trash_spec.js @@ -1,3 +1,5 @@ +const mockfs = require('mock-fs') + require('../../spec_helper') const fs = require('fs') @@ -29,10 +31,14 @@ const expectDirectoriesExist = function (basePath) { } describe('lib/util/trash', () => { + beforeEach(() => { + mockfs({}) + }) + context('.folder', () => { it('trashes contents of directory in non-Linux', () => { sinon.stub(os, 'platform').returns('darwin') - const basePath = path.join('foo') + const basePath = 'foo' populateDirectories(basePath) @@ -52,7 +58,7 @@ describe('lib/util/trash', () => { it('completely removes directory on Linux', () => { sinon.stub(os, 'platform').returns('linux') - const basePath = path.join('foo') + const basePath = 'foo' populateDirectories(basePath) diff --git a/packages/server/test/unit/util/tty_spec.js b/packages/server/test/unit/util/tty_spec.js index 308ea150d3b5..3c918601c15f 100644 --- a/packages/server/test/unit/util/tty_spec.js +++ b/packages/server/test/unit/util/tty_spec.js @@ -8,17 +8,6 @@ const ttys = [process.stdin.isTTY, process.stdout.isTTY, process.stderr.isTTY] describe('lib/util/tty', () => { context('getWindowSize', () => { - // https://github.com/cypress-io/cypress/issues/1815 - // windows has undefined process.stdout.getWindowSize - // when running in electron, even when stdio inherited - beforeEach(() => { - // need to delete both the initial module and the - // "base.js" module with problematic tty.getWindowSize call - delete require.cache[require.resolve('mocha-7.0.1/lib/reporters/base')] - - return delete require.cache[require.resolve('mocha-7.0.1/lib/reporters')] - }) - it('polyfills stdout and stderr getWindowSize', () => { sinon.stub(tty, 'isatty').returns(true) sinon.stub(terminalSize, 'get').returns({ columns: 10, rows: 20 }) @@ -28,15 +17,8 @@ describe('lib/util/tty', () => { ttyUtil.override() - // forces mocha reporters base to use tty.getWindowSize() - // check the terminal width - should be the ttyUtil hardcoded - require('mocha-7.0.1/lib/reporters') - const base = require('mocha-7.0.1/lib/reporters/base') - expect(process.stdout.getWindowSize()).to.deep.eq([10, 20]) expect(process.stderr.getWindowSize()).to.deep.eq([10, 20]) - - expect(base.window.width).to.equal(10) }) })