From dd829249122948fd66dd885dbd39a0cd9167118d Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sat, 25 Sep 2021 17:11:29 +0000 Subject: Tweak jest configuration --- .eslintrc.json | 3 +-- package.json | 8 ++++++-- src/routes.test.ts | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5eff963..26cbded 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,8 +8,7 @@ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended", - "prettier/@typescript-eslint" + "plugin:prettier/recommended" ], "rules": { "no-var": "error", diff --git a/package.json b/package.json index 271dd1a..deda25d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint": "eslint 'src/**/*.ts'", "lint:fix": "eslint --fix 'src/**/*.ts'", "test": "jest", - "test:coverage": "jest --coverage --coverageReporters cobertura", + "test:coverage": "jest --coverage", "tsc": "tsc", "doc": "typedoc src" }, @@ -80,6 +80,10 @@ "lines": 85, "statements": 85 } - } + }, + "coverageReporters": [ + "cobertura", + "text" + ] } } diff --git a/src/routes.test.ts b/src/routes.test.ts index 7f275b9..dc2b6a6 100644 --- a/src/routes.test.ts +++ b/src/routes.test.ts @@ -23,6 +23,28 @@ test("HOST_DIR must be readable and writable", () => { ).not.toThrowError(); }); +import { Writable } from "stream"; +import winston from "winston"; + +let output = ""; + +jest.mock("./util/logger", () => { + const stream = new Writable(); + stream._write = (chunk, _encoding, next) => { + output = output += chunk.toString(); + next(); + }; + const streamTransport = new winston.transports.Stream({ stream }); + + return { + __esModule: true, + default: () => ({ + format: winston.format.combine(winston.format.splat(), winston.format.simple()), + transports: [streamTransport] + }) + } +}); + import { configOrError, persistTemplate } from "./util/config"; import routes from "./routes"; import Metadata, { EnvConfig } from "./metadata"; -- cgit