Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing #906

Open
xenoterracide opened this issue Nov 23, 2022 · 0 comments
Open

testing #906

xenoterracide opened this issue Nov 23, 2022 · 0 comments

Comments

@xenoterracide
Copy link

xenoterracide commented Nov 23, 2022

I can't seem to figure out how to get this to work well in testing. This is how I've figured out how to get it to work

  beforeAll(async () => {
    module = await Test.createTestingModule({
      imports: [
        MongoRepositoryLocalModule,
        TypeOrmTestModule,
        StorefrontModule,
      ],
    })
      .setLogger(new Log4jsLogger(getLogger()))
      .compile();
  });

Applying the module directly in createTestingModule did nothing.

we have this LoggerModule that I added it to

import { Global, Module } from '@nestjs/common';
import { Log4jsModule } from '@nestx-log4js/core';

import { LoggerFactory } from './logger.factory';

@Global()
@Module({
  imports: [Log4jsModule.forRoot()],
  providers: [
    {
      provide: LoggerFactory,
      useFactory: () => new LoggerFactory(),
    },
  ],
  exports: [LoggerFactory],
})
export class LoggerModule {}

which is imported by StorefrontModule

@Module({
  imports: [
    TypeOrmModule.forFeature([StorefrontProductAggregate]),
    LoggerModule,
  ],
  providers: [FixtureService, StorefrontProductRepository],
  exports: [StorefrontProductRepository],
})
export class StorefrontModule {}

but still nothing. setting the logger for the app is the only way I've been able to get it to work there too, but that's really late bound. There's got to be a better way. We don't seem to be overriding the base logger either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant