From 9da7b8db2c76e2ecec30f6f9ef62eaa30b9a62e1 Mon Sep 17 00:00:00 2001 From: Omer Van kloeten Date: Sun, 18 Feb 2024 10:15:55 +0200 Subject: [PATCH] Jest shouldn't run tests from dist --- jest.config.js | 7 ++++--- packages/design/jest.config.js | 5 ----- packages/design/package.json | 2 +- packages/interfaces/package.json | 2 +- packages/interfaces/store.ts | 1 - packages/run/jest.config.js | 5 ----- packages/run/package.json | 2 +- packages/run/src/workflow-factory.ts | 10 +++++++++- packages/test/package.json | 2 +- 9 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 packages/design/jest.config.js delete mode 100644 packages/run/jest.config.js diff --git a/jest.config.js b/jest.config.js index b413e10..284dc91 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,6 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', -}; \ No newline at end of file + preset: 'ts-jest', + testEnvironment: 'node', + testPathIgnorePatterns: ['/node_modules/', '/dist/'], +} diff --git a/packages/design/jest.config.js b/packages/design/jest.config.js deleted file mode 100644 index b413e10..0000000 --- a/packages/design/jest.config.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @type {import('ts-jest').JestConfigWithTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', -}; \ No newline at end of file diff --git a/packages/design/package.json b/packages/design/package.json index e49dfa5..214867d 100644 --- a/packages/design/package.json +++ b/packages/design/package.json @@ -23,7 +23,7 @@ }, "scripts": { "compile": "tsc-silent --project tsconfig.json --suppress 1344@src/diagram/parser.js --compiler ../../node_modules/typescript/lib/typescript.js", - "test": "jest", + "test": "jest --config=../../jest.config.js", "generate": "jison src/diagram/stateDiagram.jison --outfile src/diagram/parser.js --module-type commonjs", "lint": "eslint **/*.ts --fix" }, diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 9af48f9..02df76b 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -4,7 +4,7 @@ "description": "Interfaces between the different modules of Gamgee", "devDependencies": {}, "scripts": { - "test": "jest", + "test": "jest --config=../../jest.config.js", "lint": "eslint **/*.ts --fix" }, "author": "Omer van Kloeten", diff --git a/packages/interfaces/store.ts b/packages/interfaces/store.ts index 51cb325..1ec69e2 100644 --- a/packages/interfaces/store.ts +++ b/packages/interfaces/store.ts @@ -3,7 +3,6 @@ import { WorkflowTask } from './task' export enum FetchStrategy { Newest = 'LIFO', Oldest = 'FIFO', - Drain = 'Drain', // Pick up everything except for first tasks. TODO: How should this be implemented this time? } export type Query = Partial<{ workflowType: string; taskName: string; strategy: FetchStrategy }> diff --git a/packages/run/jest.config.js b/packages/run/jest.config.js deleted file mode 100644 index b413e10..0000000 --- a/packages/run/jest.config.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @type {import('ts-jest').JestConfigWithTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', -}; \ No newline at end of file diff --git a/packages/run/package.json b/packages/run/package.json index b162a2f..f98e8e9 100644 --- a/packages/run/package.json +++ b/packages/run/package.json @@ -17,7 +17,7 @@ "scripts": { "generate": "mm2ws test/**/*.mermaid", "compile": "tsc --build .", - "test": "jest", + "test": "jest --config=../../jest.config.js", "lint": "eslint **/*.ts --fix" }, "author": "Omer van Kloeten", diff --git a/packages/run/src/workflow-factory.ts b/packages/run/src/workflow-factory.ts index edeef2c..4917fcf 100644 --- a/packages/run/src/workflow-factory.ts +++ b/packages/run/src/workflow-factory.ts @@ -9,7 +9,15 @@ class WorkflowFactory { } create(workflowType: string) { - return this.workflows[workflowType]() + const workflowCreator = this.workflows[workflowType] + + if (!workflowCreator) { + throw new Error( + `Unable to initialize workflow of type ${workflowType}. Please check that it was registered by the generated code.`, + ) + } + + return workflowCreator() } } diff --git a/packages/test/package.json b/packages/test/package.json index 2dc0635..0888ee7 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -14,7 +14,7 @@ }, "scripts": { "compile": "tsc --build .", - "test": "jest", + "test": "jest --config=../../jest.config.js", "lint": "eslint **/*.ts --fix" }, "author": "Omer van Kloeten",