From 0eea6d4e27e148d35fa8adaae5516c6a9cbe0fa3 Mon Sep 17 00:00:00 2001 From: Bart Mesuere Date: Thu, 20 Jun 2024 10:21:03 +0200 Subject: [PATCH] fix tests --- jest.config.ts | 2 +- package.json | 2 +- tests/commands/peptfilter.test.ts | 8 ++++---- tests/commands/uniprot.test.ts | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 9627c0f6..9b51f878 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -104,7 +104,7 @@ const config: Config = { // notifyMode: "failure-change", // A preset that is used as a base for Jest's configuration - // preset: undefined, + preset: 'ts-jest/presets/default-esm', // Run tests from one or more projects // projects: undefined, diff --git a/package.json b/package.json index 7daaa389..ddaa71bc 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "scripts": { "build": "yarn run tsc", "lint": "yarn run eslint", - "test": "yarn run jest", + "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' yarn run jest", "typecheck": "yarn tsc --skipLibCheck --noEmit", "peptfilter": "yarn run tsx bin/peptfilter.ts", "uniprot": "yarn run tsx bin/uniprot.ts" diff --git a/tests/commands/peptfilter.test.ts b/tests/commands/peptfilter.test.ts index 07bb7f20..ad1cfff1 100644 --- a/tests/commands/peptfilter.test.ts +++ b/tests/commands/peptfilter.test.ts @@ -1,4 +1,5 @@ import { Peptfilter } from '../../lib/commands/peptfilter'; +import { jest } from '@jest/globals'; import * as mock from 'mock-stdin'; let output: string[]; @@ -54,9 +55,8 @@ test('test default filter from stdin', async () => { await run; - expect(writeSpy).toHaveBeenCalledTimes(1); expect(errorSpy).toHaveBeenCalledTimes(0); - expect(output.length).toBe(1); + expect(output.join("").trimEnd().split("\n").length).toBe(1); }); test('test if it passes fasta from stdin', async () => { @@ -71,8 +71,8 @@ test('test if it passes fasta from stdin', async () => { await run; - expect(writeSpy).toHaveBeenCalledTimes(1); expect(errorSpy).toHaveBeenCalledTimes(0); + expect(output.join("").trimEnd().split("\n").length).toBe(1); expect(output[0]).toBe(">AA\n"); }); @@ -92,7 +92,7 @@ test('test complex example from stdin', async () => { await run; - expect(writeSpy).toHaveBeenCalledTimes(1); expect(errorSpy).toHaveBeenCalledTimes(0); + expect(output.join("").trimEnd().split("\n").length).toBe(1); expect(output[0]).toBe("CCCCCA\n"); }); diff --git a/tests/commands/uniprot.test.ts b/tests/commands/uniprot.test.ts index ca72837b..59ba4f7f 100644 --- a/tests/commands/uniprot.test.ts +++ b/tests/commands/uniprot.test.ts @@ -1,4 +1,5 @@ import { Uniprot } from '../../lib/commands/uniprot'; +import { jest } from '@jest/globals'; import * as mock from 'mock-stdin'; let output: string[];