From 1662aa7802e58de82147d9567ab82cc264db9217 Mon Sep 17 00:00:00 2001 From: Mathieu Collette Date: Tue, 16 Jul 2024 18:01:50 +0200 Subject: [PATCH] feat: test --- apps/pathway-design/server/src/app/app.controller.ts | 2 ++ .../server/src/tests/{step.ts => index.step.ts} | 0 apps/pathway-design/server/tsconfig.app.json | 3 +-- apps/pathway-design/server/tsconfig.json | 4 +++- apps/pathway-design/server/tsconfig.spec.json | 6 ++++-- docs/nx/generators.md | 2 +- .../creation/server/business/entities/pathway/.swcrc | 9 +-------- .../server/business/entities/pathway/tsconfig.json | 2 +- .../server/business/entities/pathway/tsconfig.lib.json | 5 ++--- .../server/business/usecases/init-pathway/.swcrc | 2 +- .../business/usecases/init-pathway/src/lib/index.feature | 1 - .../business/usecases/init-pathway/src/lib/index.step.ts | 7 ++----- tsconfig.base.json | 2 +- 13 files changed, 19 insertions(+), 26 deletions(-) rename apps/pathway-design/server/src/tests/{step.ts => index.step.ts} (100%) diff --git a/apps/pathway-design/server/src/app/app.controller.ts b/apps/pathway-design/server/src/app/app.controller.ts index 5151f57c..80b9a310 100644 --- a/apps/pathway-design/server/src/app/app.controller.ts +++ b/apps/pathway-design/server/src/app/app.controller.ts @@ -1,5 +1,6 @@ import { Controller, Get, Inject } from '@nestjs/common'; +import { PathwayDesignCreationServerBusinessEntitiesPathway } from '@bewoak/pathway-design-creation-server-business-entities-pathway'; import { AppService } from './app.service'; @Controller() @@ -8,6 +9,7 @@ export class AppController { @Get() getData() { + new PathwayDesignCreationServerBusinessEntitiesPathway('name'); return this.appService.getData(); } } diff --git a/apps/pathway-design/server/src/tests/step.ts b/apps/pathway-design/server/src/tests/index.step.ts similarity index 100% rename from apps/pathway-design/server/src/tests/step.ts rename to apps/pathway-design/server/src/tests/index.step.ts diff --git a/apps/pathway-design/server/tsconfig.app.json b/apps/pathway-design/server/tsconfig.app.json index 27f57525..b4768c1b 100644 --- a/apps/pathway-design/server/tsconfig.app.json +++ b/apps/pathway-design/server/tsconfig.app.json @@ -10,8 +10,7 @@ "noImplicitAny": true, "strictBindCallApply": true, "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "composite": true + "noFallthroughCasesInSwitch": true }, "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.step.ts"], "include": ["src/**/*.ts"] diff --git a/apps/pathway-design/server/tsconfig.json b/apps/pathway-design/server/tsconfig.json index 7b0c38d3..82905d74 100644 --- a/apps/pathway-design/server/tsconfig.json +++ b/apps/pathway-design/server/tsconfig.json @@ -5,10 +5,12 @@ "references": [ { "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.spec.json" } ], "compilerOptions": { - "esModuleInterop": true, "declaration": true } } diff --git a/apps/pathway-design/server/tsconfig.spec.json b/apps/pathway-design/server/tsconfig.spec.json index dbd645e0..0446a407 100644 --- a/apps/pathway-design/server/tsconfig.spec.json +++ b/apps/pathway-design/server/tsconfig.spec.json @@ -2,6 +2,8 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "CommonJS", - "esModuleInterop": true - } + "esModuleInterop": true, + "composite": true + }, + "include": ["src/**/*.ts"] } diff --git a/docs/nx/generators.md b/docs/nx/generators.md index db1ae0b9..377f5bc2 100644 --- a/docs/nx/generators.md +++ b/docs/nx/generators.md @@ -13,7 +13,7 @@ bun run nx generate @nx/js:lib --name=init-pathway --bundler=swc --directory=lib ### Create a Nx:Nest:Library ```bash -bun run nx generate @nx/nest:lib --name=pathway --buildable --publishable --directory=libs/pathway-design/creation/server/business/entities --importPath=@bewoak/pathway-design-creation-server-business-entities-pathway --linter=none --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived --standaloneConfig +bun run nx generate @nx/nest:lib --name=pathway --buildable --publishable --directory=libs/pathway-design/creation/server/business/entities --importPath=@bewoak/pathway-design-creation-server-business-entities-pathway --linter=none --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived --standaloneConfig -d ``` ### Convert a Nx:Library to swc compiler diff --git a/libs/pathway-design/creation/server/business/entities/pathway/.swcrc b/libs/pathway-design/creation/server/business/entities/pathway/.swcrc index be4d8fcd..55b8046d 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/.swcrc +++ b/libs/pathway-design/creation/server/business/entities/pathway/.swcrc @@ -18,12 +18,5 @@ "type": "commonjs" }, "sourceMaps": true, - "exclude": [ - "jest.config.ts", - ".*\\.spec.tsx?$", - ".*\\.test.tsx?$", - "./src/jest-setup.ts$", - "./**/jest-setup.ts$", - ".*.js$" - ] + "exclude": [".*\\.spec.tsx?$", ".*\\.test.tsx?$", ".*.js$"] } diff --git a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json b/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json index bdb756aa..fb41e70d 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json +++ b/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../../../../../../tsconfig.base.json", "compilerOptions": { - "module": "esnext", + "module": "commonjs", "forceConsistentCasingInFileNames": true, "strict": true, "noImplicitOverride": true, diff --git a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json b/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json index 5e6965bf..e03aa727 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json +++ b/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json @@ -9,9 +9,8 @@ "noImplicitAny": true, "strictBindCallApply": true, "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "composite": true + "noFallthroughCasesInSwitch": true }, "include": ["src/**/*.ts"], - "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"] + "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.step.ts"] } diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/.swcrc b/libs/pathway-design/creation/server/business/usecases/init-pathway/.swcrc index 55b8046d..c3a00aec 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/.swcrc +++ b/libs/pathway-design/creation/server/business/usecases/init-pathway/.swcrc @@ -18,5 +18,5 @@ "type": "commonjs" }, "sourceMaps": true, - "exclude": [".*\\.spec.tsx?$", ".*\\.test.tsx?$", ".*.js$"] + "exclude": [".*\\.spec.tsx?$", ".*\\.step.ts$", ".*\\.test.tsx?$", ".*.js$"] } diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature index bbafae55..46855e0e 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature +++ b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature @@ -1,6 +1,5 @@ Feature: Initiate Pathway Scenario: I want to initiate a pathway - Given I am an author When I initiate a pathway with the name "My Pathway" Then I should retrieve a pathway initiated with the name "My Pathway" diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts index 7d9c0e7f..6ce51d83 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts +++ b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts @@ -1,6 +1,6 @@ -import { strict as assert } from 'node:assert'; import type { PathwayDesignCreationServerBusinessEntitiesPathway } from '@bewoak/pathway-design-creation-server-business-entities-pathway'; -import { binding, given, then, when } from 'cucumber-tsflow'; +import { binding, then, when } from 'cucumber-tsflow'; +import { strict as assert } from 'node:assert'; import { PathwayDesignCreationServerBusinessUsecasesInitPathway } from './index.usecase'; @binding() @@ -11,9 +11,6 @@ class ControllerSteps { | PathwayDesignCreationServerBusinessEntitiesPathway | undefined; - @given('I am an author') - public givenIAmAnAuthor() {} - @when('I initiate a pathway with the name {string}') public whenIInitiateAPathway(name: string) { this.pathway = this.initPathwayUsecase?.execute({ name }); diff --git a/tsconfig.base.json b/tsconfig.base.json index bad70418..ecce46f1 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -8,7 +8,7 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, - "target": "es2020", + "target": "es2015", "module": "esnext", "lib": ["es2020", "dom"], "skipLibCheck": true,