testable-nodejs-api
testable-nodejs-api copied to clipboard
Error: timeout of 2000ms
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)
1) "before each" hook for "should return a list of books"
Routes: Users
GET /users
Executing (default): DELETE FROM Users
Executing (default): INSERT INTO Users (id,name,email,password,created_at,updated_at) VALUES (NULL,'John','[email protected]','$2a$10$4jP116Ra4t3fFuh454DW0ezs8r0OhKKeiGn9tT2yWKOZ6L3qczpDy','2017-12-09 00:10:37.715 +00:00','2017-12-09 00:10:37.715 +00:00');
Executing (default): INSERT INTO Users (id,name,email,password,created_at,updated_at) VALUES (1,'Test User','[email protected]','$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)
2) "before each" hook for "should return a list of users"
0 passing (4s) 2 failing
-
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.
-
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?
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(); }); });