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

Default template Unit Tests fail #36

Closed
laser-cake opened this issue Sep 21, 2020 · 1 comment · Fixed by #54
Closed

Default template Unit Tests fail #36

laser-cake opened this issue Sep 21, 2020 · 1 comment · Fixed by #54
Labels
🐞 Bug Something isn't working

Comments

@laser-cake
Copy link

When running the unit tests in the default version, the auth.test.ts fails:

` src/tests/auth.test.ts:25:36 - error TS2339: Property 'path' does not exist on type 'AuthRoute'.

25                 .post(`${authRoute.path}/signup`)
                                      ~~~~
src/tests/auth.test.ts:41:36 - error TS2339: Property 'path' does not exist on type 'AuthRoute'.

41                 .post(`${authRoute.path}/login`)
                                      ~~~~
src/tests/auth.test.ts:53:36 - error TS2339: Property 'path' does not exist on type 'AuthRoute'.

53                 .post(`${authRoute.path}/logout`)`

Even if this compilation error is fixed, the tests still fail:

FAIL src/tests/auth.test.ts (7.321 s)
● Testing Auth › [POST] /login › response should have the Set-Cookie header with the Authorization token

expected "Set-Cookie" header field

  at Test._assertHeader (node_modules/supertest/lib/test.js:237:45)
  at Test._assertFunction (node_modules/supertest/lib/test.js:283:11)
  at Test.assert (node_modules/supertest/lib/test.js:173:18)
  at Server.localAssert (node_modules/supertest/lib/test.js:131:12)

● Testing Auth › [POST] /logout › logout Set-Cookie Authorization=; Max-age=0

expected "Set-Cookie" header field

  at Test._assertHeader (node_modules/supertest/lib/test.js:237:45)
  at Test._assertFunction (node_modules/supertest/lib/test.js:283:11)
  at Test.assert (node_modules/supertest/lib/test.js:173:18)
  at Server.localAssert (node_modules/supertest/lib/test.js:131:12)

In the sequelize template I get the following:

FAIL src/tests/auth.test.ts
● Test suite failed to run

src/tests/users.test.ts:15:13 - error TS2740: Type 'typeof User' is missing the following properties from type 'User[]': pop, push, concat, join, and 25 more.

15       const findUser: User[] = userModel;
               ~~~~~~~~
src/tests/users.test.ts:28:40 - error TS2339: Property 'find' does not exist on type 'typeof User'.

28       const findUser: User = userModel.find(user => user.id === userId);
                                          ~~~~
src/tests/users.test.ts:28:45 - error TS7006: Parameter 'user' implicitly has an 'any' type.

28       const findUser: User = userModel.find(user => user.id === userId);
                                               ~~~~
src/tests/users.test.ts:74:44 - error TS2339: Property 'filter' does not exist on type 'typeof User'.

74       const deleteUser: User[] = userModel.filter(user => user.id !== userId);
                                              ~~~~~~
src/tests/users.test.ts:74:51 - error TS7006: Parameter 'user' implicitly has an 'any' type.

74       const deleteUser: User[] = userModel.filter(user => user.id !== userId);
                                                     ~~~~

FAIL src/tests/users.test.ts
● Test suite failed to run

src/models/index.model.ts:25:22 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type 'typeof User' is not assignable to type 'string | ModelCtor<Model<any, any>>'.
      Type 'typeof User' is not assignable to type 'ModelCtor<Model<any, any>>'.
        Type 'typeof User' is not assignable to type 'typeof Model'.
          Construct signature return types 'User' and 'Model<T, T2>' are incompatible.
            The types of '_attributes' are incompatible between these types.
              Type 'User' is not assignable to type 'T'.
                'T' could be instantiated with an arbitrary type which could be unrelated to 'User'.

25 sequelize.addModels([User]);
                        ~~~~

  node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.d.ts:16:5
    16     addModels(arg: Array<ModelCtor | string>): any;
           ~~~~~~~~~
    The last overload is declared here.

FAIL src/tests/index.test.ts
● Test suite failed to run

TypeError: Cannot read property 'getQueryInterface' of undefined

  at Function.get queryInterface [as queryInterface] (node_modules/sequelize/lib/model.js:55:27)
  at isFunctionMember (node_modules/sequelize-typescript/dist/model/model/model.js:99:25)
  at node_modules/sequelize-typescript/dist/model/model/model.js:96:5
      at Array.filter (<anonymous>)
  at Object.<anonymous> (node_modules/sequelize-typescript/dist/model/model/model.js:95:6)
  at Object.<anonymous> (node_modules/sequelize-typescript/dist/model/shared/model-service.js:3:17)

I've not tried the mongoose version, but I'm guessing that will have similiar issues. I'm guessing these are still work in progress.

@ljlm0402
Copy link
Owner

@laser-cake

We apologize for any inconvenience. We will fix it as soon as possible.

@ljlm0402 ljlm0402 added the 🐞 Bug Something isn't working label Nov 10, 2020
@ljlm0402 ljlm0402 linked a pull request Dec 17, 2020 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants