Open marcoaureliovrs opened 6 years ago
Descobri a solução para o teste automatizado de Users:
beforeEach(done => { Users .destroy({where: {}}) .then(() => Users.create(defaultUser)) .then(user => { token = jwt.encode({id: user.id}, jwtSecret); done(); }); });
Boa Noite Waldemar,
Eu fiz o seu curso no youtube sobre TDD e tive dificuldade na fase final, os testes começaram a retornar timeout após implementar a autenticação com jwt. Fiz o download da sua versão aqui no github executei e retornou o mesmo erro que esta retornando pra mim:
Routes: Books GET /books Executing (default): DELETE FROM
Users
Unhandled rejection SequelizeBaseError: SQLITE_ERROR: no such table: Users at Query.formatError (/Users/marcogorak/Downloads/testable-nodejs-api-master/node_modules/sequelize/lib/dialects/sqlite/query.js:348:14) at afterExecute (/Users/marcogorak/Downloads/testable-nodejs-api-master/node_modules/sequelize/lib/dialects/sqlite/query.js:112:29) at Statement.errBack (/Users/marcogorak/Downloads/testable-nodejs-api-master/node_modules/sqlite3/lib/sqlite3.js:16:21)Routes: Users GET /users Executing (default): DELETE FROM
Users
Executing (default): INSERT INTOUsers
(id
,name
,email
,password
,created_at
,updated_at
) VALUES (NULL,'John','john@gmail.com','$2a$10$4jP116Ra4t3fFuh454DW0ezs8r0OhKKeiGn9tT2yWKOZ6L3qczpDy','2017-12-09 00:10:37.715 +00:00','2017-12-09 00:10:37.715 +00:00'); Executing (default): INSERT INTOUsers
(id
,name
,email
,password
,created_at
,updated_at
) VALUES (1,'Test User','test@mail.com','$2a$10$oK0Rty8IHv6e/UGVKYQtU.AwjuPXyyPXehsFV5AEfHQsUhFjfH7Si','2017-12-09 00:10:37.825 +00:00','2017-12-09 00:10:37.825 +00:00'); Unhandled rejection SequelizeBaseError: Validation error at Query.formatError (/Users/marcogorak/Downloads/testable-nodejs-api-master/node_modules/sequelize/lib/dialects/sqlite/query.js:337:14) at Statement.afterExecute (/Users/marcogorak/Downloads/testable-nodejs-api-master/node_modules/sequelize/lib/dialects/sqlite/query.js:112:29) at Statement.replacement (/Users/marcogorak/Downloads/testable-nodejs-api-master/node_modules/sqlite3/lib/trace.js:19:31)0 passing (4s) 2 failing
1) Routes: Books "before each" hook for "should return a list of books": Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
2) Routes: Users "before each" hook for "should return a list of users": Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
Poderia me ajudar?