e2e Generation is failed
I Try to generate e2e. That's what I did(I run these commands one after another):
"generate:test": "npx nestia e2e --config nestia.config.ts --project test/tsconfig.json",
"build:test": "rimraf bin && tsc -p test/tsconfig.json",
"start:test": "node bin/test/index.js > bin/test/log.ans",
This is my test/tsconfig
{
"extends": "../tsconfig.json",
"compilerOptions": {
"esModuleInterop": false,
"outDir": "../bin",
},
"include": [".", "../src"]
}
This is parent
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"resolveJsonModule": true,
"outDir": "./dist",
"esModuleInterop": false, //<-ломает генерацию тестов
"baseUrl": "",
"paths": {
"@validation/*": ["src/validation/dto/*"],
"@services/*": ["src/services/*"],
"@cfg/*": ["src/configs/*"],
"@modules/*": ["src/modules/*"],
"@helpers/*": ["src/helpers/*"],
"@interfaces/*": ["src/interfaces/*"],
"@shared*": ["src/validation/dto/shared/*"],
"@root/*": ["src/*"],
"@const/*": ["src/constants/*"]
},
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"plugins": [
{
"transform": "@nestia/core/lib/transform",
"validate": "assert",
"stringify": "assert"
},
{
"transform": "typia/lib/transform"
},
{ "transform": "typescript-transform-paths" }
]
},
"include": ["src", "nestia.config.ts"]
}
Nestia.config.ts
import { INestiaConfig } from '@nestia/sdk';
import { NestFactory } from '@nestjs/core';
// import { FastifyAdaptor } from "@nestjs/platform-fastify";
import { AppModule } from '@root/app.module';
const NESTIA_CONFIG: INestiaConfig = {
input: async () => {
const app = await NestFactory.create(AppModule);
// const app = await NestFactory.create(YourModule, new FastifyAdaptor());
// app.setGlobalPrefix("api");
// app.enableVersioning({
// type: VersioningType.URI,
// prefix: "v",
// })
return app;
},
swagger: {
output: 'packages/api/swagger.json',
beautify: true,
security: {
bearer: {
type: 'apiKey',
name: 'Authorization',
in: 'header',
},
},
servers: [
{
url: 'http://localhost:3456',
description: 'Local Server',
},
],
},
primitive: false,
simulate: true,
output: 'src/api',
distribute: 'packages/api',
e2e: 'test',
};
export default NESTIA_CONFIG;
I'm getting something strange in index.ts in tests in await core.DynamicModule.mount like the picture below. I change this to AppModule manually. How to avoid this problem?
Next I try to run the command
"build:test": "rimraf bin && tsc -p test/tsconfig.json"
And I get a million of these errors:
test/features/api/automated/test_api_users_updateUser.ts:1:15 - error TS2617: 'e' can only be imported by using 'import e = require("@types/express/index")' or by turning on the 'esModuleInterop' flag and using a default import.
1 import type { e } from "@types/express/index";
~
test/features/api/automated/test_api_users_updateUser.ts:1:24 - error TS6137: Cannot import type declaration files. Consider importing 'express/index' instead of '@types/express/index'.
1 import type { e } from "@types/express/index";
How can this be fixed? I tried changing different tsconfig settings, such as strict, esModuleInterop and something else, but I was unable to compile and run the tests without errors. Since this error() was related to typing, I could simply ignore it and run
start:test": "node bin/test/index.js > bin/test/log.ans.
But it's kind of hard to fix it every time.
May I use the same reproducible repo with #922?
https://github.com/samchon/nestia/blob/master/packages/core/src/decorators/DynamicModule.ts
About the DynamicModule, this is the type of it. In your case, you can just mount controllers by only writing a string literal value "src/modules/**/*.controller.ts".
May I use the same reproducible repo with #922? I recreated this repository from your template. I think that there will not be the same error because everything is configured by you, I can try to change it according to the structure of my project, but I am not sure if this will reproduce the error. I'll try to change the repository and post if I can reproduce the problem
https://github.com/samchon/nestia/blob/master/packages/core/src/decorators/DynamicModule.ts
About the
DynamicModule, this is the type of it. In your case, you can just mount controllers by only writing a string literal value"src/modules/**/*.controller.ts".
I'm a very lazy person) Is it possible to somehow register this setting in the nestia config so that you don’t have to go into the generated file every time and fix it manually?If you have to somehow automate this process, it will be impossible due to incorrect generation of mount contents and errors with
import type { e } from "@types/express/index";
@samchon ?
No way to fully consider every use cases about the application bootstrapping, gave up index.ts file generation, and decided to generate only individual test functions.
If you upgrade to 3.11.1 version, you can meet the change.