Complete the code to import the testing module for integration tests in NestJS.
import { Test, TestingModule } from '@nestjs/[1]';
The correct import for NestJS testing utilities is from '@nestjs/testing'.
Complete the code to create a testing module with the AppModule imported.
const moduleRef: TestingModule = await Test.createTestingModule({ imports: [[1]] }).compile();The main application module is usually named AppModule and should be imported as is.
Fix the error in the code to get the service instance from the testing module.
const service = moduleRef.[1](MyService);The correct method to get a provider instance from the testing module is get().
Fill both blanks to correctly initialize and close the NestJS application in the test.
app = moduleRef.[1](); await app.[2]();
Use createNestApplication() to create the app instance and close() to clean up after tests.
Fill all three blanks to write a test that checks if the service method returns the expected value.
it('should return expected result', async () => { const result = await service.[1](); expect(result).[2]([3]); });
The test calls getData() on the service, then expects the result to equal the string 'expected value'.