From b9828bb58dceac2b405a52b36ebe40b88b7d4cb3 Mon Sep 17 00:00:00 2001 From: Dmitrii Sorin Date: Sat, 22 Jun 2019 22:23:52 +1000 Subject: [PATCH] Fix tty issue --- src/subprocess/thread/worker.development.js | 5 ----- src/subprocess/thread/worker.ts | 6 +++++- test/run-programmatically/tty-worker/README | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/subprocess/thread/worker.development.js b/src/subprocess/thread/worker.development.js index 302ba0d..9ece0a3 100644 --- a/src/subprocess/thread/worker.development.js +++ b/src/subprocess/thread/worker.development.js @@ -2,10 +2,5 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const { register: registerTypescriptHandler } = require('ts-node'); -// monkeypatch Node.JS native TTY function -// otherwise mocha native base reporter throws exception -// inside a worker environment -require('tty').getWindowSize = () => 75; - registerTypescriptHandler(); require(`${__dirname}/worker.ts`); diff --git a/src/subprocess/thread/worker.ts b/src/subprocess/thread/worker.ts index d4e9b66..b895072 100644 --- a/src/subprocess/thread/worker.ts +++ b/src/subprocess/thread/worker.ts @@ -1,5 +1,9 @@ -import { workerData } from 'worker_threads'; +// monkeypatch Node.JS native TTY function +// otherwise mocha native base reporter throws exception +// inside a worker environment +require('tty').getWindowSize = () => 75; +import { workerData } from 'worker_threads'; import { runMocha } from '../runner'; import { WorkerData } from '../../main/thread/worker'; diff --git a/test/run-programmatically/tty-worker/README b/test/run-programmatically/tty-worker/README index f46744c..e8715b1 100644 --- a/test/run-programmatically/tty-worker/README +++ b/test/run-programmatically/tty-worker/README @@ -1 +1,2 @@ Check that spec reporter can work in a non-TTY window +TODO: this test fails when you run index.js from the terminal but doesn't fail when it's executed from tests/index.sh