You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if @OgmaLogger() is used in any test the error Error: Expected OgmaCoreModule to be configured by at last one Module but it was not configured within 0ms will appear in the console. While this doesn't fail the test, because it is an UnhandledPromiseRejection it may end up failing in the future.
describe('AppService',()=>{letservice: AppService;beforeEach(async()=>{constmodRef=awaitTest.createTestingModule({providers: [AppService,{provide: 'OGMA_SERVICE:AppService',useValue: {log: jest.fn(),}}]}).compile();service=modRef.get(AppService);});it('should be defined',()=>{expect(service).toBeTruthy();});it('should return { hello: world }',()=>{expect(service.getHello()).toEqual({hello: 'world'});});});
Expected behavior
No errors to arise when running unit tests.
Possible Solution
In the OgmaModule's @Module() metadata, imports: [OgmaCoreModule.Deferred] is used. Because of this, and because it is in a decorator, it gets ran immediately, which means the observable there will be fired and possibly end up erroring out. It can probably be removed as the forRoot, forRootAsync, and forFeature all use the imports directly
jmcdo29
added
bug 😭
A regression broken what was functioning properly
core 📖
Functionality related to the service or module classes
labels
Jul 23, 2020
Due to how static class members are created in JavaScript and ran at import time rather than call
time `OgmaCoreModule.Deferred` was immediately calling
`OgmaCoreModule.externallyConfigured(OgmaCoreModule, 0)` which was causing Jest and the Node REPL to
throw an error on import of `@ogma/nestjs-module`. This has been remedied and verified by unit
tests, integration tests, and manual tests with imports from the REPL itself.
fix#106
Due to how static class members are created in JavaScript and ran at import time rather than call
time `OgmaCoreModule.Deferred` was immediately calling
`OgmaCoreModule.externallyConfigured(OgmaCoreModule, 0)` which was causing Jest and the Node REPL to
throw an error on import of `@ogma/nestjs-module`. This has been remedied and verified by unit
tests, integration tests, and manual tests with imports from the REPL itself.
fix#106
Due to how static class members are created in JavaScript and ran at import time rather than call
time `OgmaCoreModule.Deferred` was immediately calling
`OgmaCoreModule.externallyConfigured(OgmaCoreModule, 0)` which was causing Jest and the Node REPL to
throw an error on import of `@ogma/nestjs-module`. This has been remedied and verified by unit
tests, integration tests, and manual tests with imports from the REPL itself.
fix#106
Bug Report
Currently, if
@OgmaLogger()
is used in any test the errorError: Expected OgmaCoreModule to be configured by at last one Module but it was not configured within 0ms
will appear in the console. While this doesn't fail the test, because it is anUnhandledPromiseRejection
it may end up failing in the future.Input Code
Expected behavior
No errors to arise when running unit tests.
Possible Solution
In the
OgmaModule
's@Module()
metadata,imports: [OgmaCoreModule.Deferred]
is used. Because of this, and because it is in a decorator, it gets ran immediately, which means the observable there will be fired and possibly end up erroring out. It can probably be removed as theforRoot
,forRootAsync
, andforFeature
all use theimports
directlyEnvironment
The text was updated successfully, but these errors were encountered: