🧪 Announcing PicJS: TypeScript/JavaScript support for PocketIC!

I think we should do that, yes. It can be included in the next major that will also bump agent-js to @icp-sdk/core v4. No ETA for now though.

1 Like

There haven’t been any recent changes to the endpoint so I’m not sure why your tests were failing. Could you please share more details on the test scenario and which assertion/call failed?

This is the test where I had to move the setTime call after the canister setup. It’s a fairly long test and scenario, so it might be hard to spot and not a must, I mean if it works, it works :wink:. But in general, I do understand correctly, setTime should normally be called before setupCanister, or are these two things unrelated?

I agree that it makes sense to set up time as early as possible to avoid a spurious time ā€œjumpā€ in the middle of a test.

Do you remember what the error looked like (or can you quickly reproduce it)?

I don’t really get a particular error message. I’m asserting the date is await pic.setTime(new Date('2025-05-12T07:53:19+00:00').getTime());, but I end up with a different date.

- Expected
+ Received

@@ -2,11 +2,11 @@

  Module: Satellite

  Amount: 0.00000014 T Cycles

- Time: 2025-05-12T07:53:19+00:00
+ Time: 2021-05-06T19:17:10+00:00

I don’t seem to have any references to the 2021-05-06 in my code.

But nvm, not sure it is worth debugging further. From my side, at this point at least, it was stricly question of understanding.

Note that set time is not visible in query calls if there’s no round executed after setting time and before executing a query call. If you want to set time and not execute a round, you can use the function to set ā€œcertifiedā€ time: this way, query calls immediately see the updated time.

That’s the default date used by PocketIC.

Good to know as well! It might be, but again, it used to work - i.e. the assertion used to succeed - so that would mean that if I use(d) query calls for that test, they worked in the past since it already passed. Anyway, probably something to leave in the backlog. Thanks for the explanation!