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

Error: timeout of 2000ms #8

Open
marcoaureliovrs opened this issue Dec 9, 2017 · 1 comment
Open

Error: timeout of 2000ms #8

marcoaureliovrs opened this issue Dec 9, 2017 · 1 comment

Comments

@marcoaureliovrs
Copy link

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','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 INTO Users (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)

  2) "before each" hook for "should return a list of users"

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?

@marcoaureliovrs
Copy link
Author

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();
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant