Comments (10)
I would like to ask you your help.
Please, clone this repo and launch unit tests with npm run test
. Some failed tests?
If all tests pass, can you open a pull request with a new failing test that reproduces your issue? Many thanks!
from metamorphosis-nestjs.
I don't see any specific fail,
But If I move the registration to the converter instead of the decorator :
@Injectable()
//@Convert(Entity, DTO)
export classEntityToDtoConverter implements Converter<Entity, Promise<DTO>> {
constructor() {
converterRegistry.register(<Converter<NewableFunction, NewableFunction>> <unknown> this, Entity, DTO);
}
public async convert(entity: DnsEntity): Promise<DnsFrontendDto> {
....
}
}
It works great, please note I assume the tests don't fail as the issue only present itself when I register multiple converters via my model providers - an only the last defined in the provider is actually constructed and registers - I assume it is related to the class extension in the decorator
from metamorphosis-nestjs.
Just added a new test in which I've created a module with 2 converters. Could you kindly pull this repo and launch again the tests? The new test suite is called multiple-converters-test-suite.spec.ts
.
Let me know, thank you.
from metamorphosis-nestjs.
jest "multiple-converters-test-suite"
FAIL tests/multiple-converters-test-suite.spec.ts
MetamorphosisNestService
✕ should convert a class in another one (21ms)
✕ should convert an array in another one (4ms)
✓ should convert a team in to a teamDto (3ms)
● MetamorphosisNestService › should convert a class in another one
METAMORPHOSIS - Not found any converter to transform source Car into CarDto
at ConversionHelper.<anonymous> (node_modules/@fabio.formosa/metamorphosis/src/service/conversion-helper.ts:37:13)
at node_modules/@fabio.formosa/metamorphosis/dist/src/service/conversion-helper.js:8:71
at __awaiter (node_modules/@fabio.formosa/metamorphosis/dist/src/service/conversion-helper.js:4:12)
at ConversionHelper._internalConvert (node_modules/@fabio.formosa/metamorphosis/dist/src/service/conversion-helper.js:37:16)
at ConversionHelper.convert (node_modules/@fabio.formosa/metamorphosis/src/service/conversion-helper.ts:26:19)
at ConversionService.<anonymous> (src/metamorphosis.service.ts:1719:56)
at src/metamorphosis.service.ts:1676:40
at __awaiter (src/metamorphosis.service.ts:1619:10)
at ConversionService.convert (src/metamorphosis.service.ts:1711:12)
at tests/car-test-factory.ts:15:57
at tests/car-test-factory.ts:8:71
● MetamorphosisNestService › should convert an array in another one
METAMORPHOSIS - Not found any converter to transform source Car into CarDto
at ConversionHelper.<anonymous> (node_modules/@fabio.formosa/metamorphosis/src/service/conversion-helper.ts:37:13)
at node_modules/@fabio.formosa/metamorphosis/dist/src/service/conversion-helper.js:8:71
at __awaiter (node_modules/@fabio.formosa/metamorphosis/dist/src/service/conversion-helper.js:4:12)
at ConversionHelper._internalConvert (node_modules/@fabio.formosa/metamorphosis/dist/src/service/conversion-helper.js:37:16)
at ConversionHelper.convert (node_modules/@fabio.formosa/metamorphosis/src/service/conversion-helper.ts:26:19)
at ConversionService.<anonymous> (src/metamorphosis.service.ts:1719:56)
at src/metamorphosis.service.ts:1676:40
at __awaiter (src/metamorphosis.service.ts:1619:10)
at ConversionService.convert (src/metamorphosis.service.ts:1711:12)
at src/metamorphosis.service.ts:1731:19
at Array.map (<anonymous>)
at ConversionService.convertAll (src/metamorphosis.service.ts:1727:36)
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
METAMORPHOSIS - Created conversion service with debugOpts true
console.log tests/converters/team-to-teamDto.converter.ts:11
Creating converter from Team to TeamDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
METAMORPHOSIS - Registered new converter TeamConverterTest for Team to TeamDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
CONVERSION SERVICE - Converting from Car to CarDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
METAMORPHOSIS - Created conversion service with debugOpts true
console.log tests/converters/team-to-teamDto.converter.ts:11
Creating converter from Team to TeamDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
METAMORPHOSIS - Registered new converter TeamConverterTest for Team to TeamDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
CONVERSION SERVICE - Converting from Car to CarDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
CONVERSION SERVICE - Converting from Car to CarDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
METAMORPHOSIS - Created conversion service with debugOpts true
console.log tests/converters/team-to-teamDto.converter.ts:11
Creating converter from Team to TeamDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
METAMORPHOSIS - Registered new converter TeamConverterTest for Team to TeamDto
console.log node_modules/@fabio.formosa/metamorphosis/dist/src/consts/log.js:11
CONVERSION SERVICE - Converting from Team to TeamDto
--------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 90.48 | 0 | 100 | 86.67 | |
index.ts | 0 | 100 | 100 | 0 | 1,2 |
metamorphosis.module.ts | 100 | 0 | 100 | 100 | 5,12 |
metamorphosis.service.ts | 100 | 0 | 100 | 100 | 10 |
-------------------------- | --------- | ---------- | --------- | --------- | ------------------- |
Test Suites: 1 failed, 1 total | |||||
Tests: 2 failed, 1 passed, 3 total | |||||
Snapshots: 0 total | |||||
Time: 1.567s |
from metamorphosis-nestjs.
Ok thank you, I'm going to install the node version you mentioned and I'll fix this bug working on the failing test.
from metamorphosis-nestjs.
Note, I was running your test also with node 12.18.1
from metamorphosis-nestjs.
Confirmed! some troubles with the decorator @convert
. No problem with node 10.x, but it happens with node 12.x.
Some change in decorators, I suppose. I'm investigating...
from metamorphosis-nestjs.
BTW, another missing functionality is to add options to be sent to the converter ( for example version from controller to convert function )
from metamorphosis-nestjs.
after move from node 12.18.1 to 12.18.4 with nest 7.5.2
Only a single Converter is registered, when checked
Hi @galwa , fixed! Just released a new version that fixes the bug.
Can you upgrade to the new version 4.0.2
?
"@fabio.formosa/metamorphosis-nest": "^4.0.2"
WRT, your last comment: please, open a new github issue with your request. It would be a request of new feature. I'd like to know something more about your use case. Thank you!
from metamorphosis-nestjs.
Thanks, that great I will test it
from metamorphosis-nestjs.
Related Issues (13)
- ConversionService: naming clash HOT 1
- Upgrade doc at typegoose support HOT 1
- async convertion method HOT 1
- Could conversion service return the exact type instead of any for convertAll? HOT 2
- Extract typegoose support in another lib
- Add a test with TypeORM
- Create Changelog
- Support request for user options to be passed to converter HOT 5
- Debug Mode flag
- Inject a custom logger
- Jest Config: exclude dist folder from coverage
- New method to convert array
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metamorphosis-nestjs.