akveo / akveo/ngx-admin-bundle-support

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

Offen
#65 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
56
Forks
30
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### 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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.