akveo / akveo/ngx-admin-bundle-support

fix(node-nest-starter-2020-04-03): backend test commands fail

Abierto
#65 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
56
Forks
30
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Problem
The test commands for the `backend` like
```sh
npm test
npm run test:e2e
```
fail due to different reasons:
1. `npm test` due to the DI cannot be resolved:
```sh
ts-jest[versions] (WARN) Version 25.1.0 of jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=22.0.0 <24.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
FAIL src/app.controller.spec.ts
AppController
root
✕ should return "API is up and running!" (14ms)

● AppController › root › should return "API is up and running!"

Nest can't resolve dependencies of the AppController (AppService, ?). Please make sure that the argument at index [1] is available in the _RootTestModule context.

at Injector.lookupComponentInExports (../node_modules/@nestjs/core/injector/injector.js:180:19)

● AppController › root › should return "API is up and running!"

TypeError: Cannot read property 'healthCheck' of undefined

23 | describe('root', () => {
24 | it('should return "API is up and running!"', () => {
> 25 | expect(appController.healthCheck()).toBe('API is up and running!');
| ^
26 | });
27 | });
28 | });

at Object.it (app.controller.spec.ts:25:28)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.155s, estimated 3s
```

2. `npm run test:e2e` it cannot connect to the database although in `npm start run:dev` things work fine. I run it as described in #64
```sh
> jest --config ./test/jest-e2e.json

ts-jest[versions] (WARN) Version 25.1.0 of jest installed has not been
tested with ts-jest. If you're experiencing issues, consider using a su
pported version (>=22.0.0 <24.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
[Nest] 94172 - 28/04/2020, 12:17 [MongooseModule] Unable to connect
to the database. Retrying (1)...
[Nest] 94172 - 28/04/2020, 12:17 [MongooseModule] Unable to connect
to the database. Retrying (2)... +3007ms
FAIL test/app.e2e-spec.ts (7.169s)
AppController (e2e)
✕ / (GET) (5008ms)

● AppController (e2e) › / (GET)

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
```
- Generally, I cannot find the expected string `'Hello World!'` elsewhere in the code, and after trying the nest starters it seems like a copy-paster from the scaffolder.
- Could you provide additional help to set up the testing properly? I'd like to develop in TDD style

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.