I'm currently facing an issue with executing an E2E test. The file structure for the E2E test is auto-generated by nestcli.
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('test');
});
});
The tests are running using mocha
, and my package.json test script command is:
"test": "mocha --exit --require ts-node/register test/**/*.spec.ts test/*.spec.ts"
The error message I'm encountering is:
1) AppController (e2e)
"before each" hook for "/ (GET)":
Error: File <root_path>/src/queuemanager/status.processor.js does not exist
at Queue.setHandler (node_modules/bull/lib/queue.js:641:13)
at Queue.process (node_modules/bull/lib/queue.js:610:8)
at option.processors.forEach (node_modules/@nestjs/bull/dist/bull.providers.js:27:27)
at Array.forEach (<anonymous>)
at buildQueue (node_modules/@nestjs/bull/dist/bull.providers.js:12:27)
at InstanceWrapper.useFactory [as metatype] (node_modules/@nestjs/bull/dist/bull.providers.js:57:20)
at Injector.instantiateClass (node_modules/@nestjs/core/injector/injector.js:289:55)
at callback (node_modules/@nestjs/core/injector/injector.js:42:41)
The project directory structure in src
is as follows:
$ tree -L 2
.
├── app.controller.ts
├── app.module.ts
├── app.service.ts
├── main.ts
└── queuemanager
├── queuemanager.controller.ts
├── queuemanager.module.ts
└── status.processor.ts
This setup closely resembles the example provided in https://github.com/nestjs/nest/tree/master/sample/26-queues. Essentially, a queue is created using status.processor.ts
to process tasks in a separate process. The queuemanager module appears like this:
import { Module } from '@nestjs/common';
import { BullModule } from '@nestjs/bull';
import { QueuemanagerController } from './queuemanager.controller';
import { join } from 'path';
@Module({
imports: [
BullModule.registerQueue({
name: 'status',
processors: [{
name: 'statusProcessing',
path: join(__dirname, 'status.processor.js')
}]
}),
],
controllers: [QueuemanagerController],
})
export class QueuemanagerModule {}
To resolve this issue, I need to provide the compiled path to the js
file. However, it seems like the test is unable to locate it correctly — possibly due to compilation errors. Any assistance on this matter would be greatly appreciated. Thank you