Anson Felder
Anson Felder

Reputation: 31

Testcafe not saving cookies, resulting in malformed JWT

I have been using testcafe for automated UI tests for an internal CRM. These tests worked well for the last 6 months, and then mysteriously started failing a week ago. The tests are able to log into our stage environment, but then once they attempt to hit our backend, the following error occurs:

UnauthorizedError: jwt malformed
   at /opt/app/node_modules/express-jwt/lib/index.js:100:22
   at /opt/app/node_modules/express-jwt/node_modules/jsonwebtoken/index.js:155:18
   at /opt/app/node_modules/async-listener/glue.js:188:31
   at _combinedTickCallback (internal/process/next_tick.js:73:7)
   at process._tickDomainCallback (internal/process/next_tick.js:128:9)
   at process.fallback (/opt/app/node_modules/async-listener/index.js:563:15)

It looks like the cookies are not being saved:

Network Cookies Tab

I am currently using Testcafe 0.19.0, but have also attempted to upgrade to v0.22.0, but that did not solve the problem.

To my knowledge, there were no infrastructure changes that would cause this.

Upvotes: 2

Views: 390

Answers (1)

Anson Felder
Anson Felder

Reputation: 31

I ended up using the following code as a work around and it seems to be working fine.

await t.wait(1500);
await t.eval(() => location.reload(true));

Upvotes: 1

Related Questions