`introspectWorkflow` _should_ be done at

introspectWorkflow should be done at the start of the test (you can think of doing introspectWorkflow where you mock other APIs and so on) - intercepted workflows with DOs should just work (if you want to mock/intercept the calls between the two, let me know)
5 Replies
flof.fly
flof.fly3w ago
Hey Luis thank you for your message. Currently i'm unable to introspect the instance being invoked by my "worker" executed inside a runInDurableObject context:
// The introspector should have intercepted exactly one workflow instance
const instances = introspector.get();
expect(instances.length).toBe(1);
// The introspector should have intercepted exactly one workflow instance
const instances = introspector.get();
expect(instances.length).toBe(1);
this fails with Actual: 0 I'll soon paste the whole test
Seekerdasbatatas
SeekerdasbatatasOP3w ago
ty, in the meantime could, you try moving .get outside of the runInDurableObject context and see if there's still no instances in the introspector list?
flof.fly
flof.fly3w ago
https://pastebin.com/frVvRBdY Modified it to not disclose our business logic, but the example is the same. We want to test a worker, that does some DO SQLite queries, then invokes a Workflow and returns the workflow id. At that point, the workflow itself, has multiple steps, and each one of those steps apply changes to the same DO. We want to check the steps, and be able to verify if expected rows in the DO SQLite were stored (i.e by another runInDurableObject on the same instance at the end of the workflow steps.)
Pastebin
workflow-durable-object.test.ts - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
flof.fly
flof.fly3w ago
Confirm, still 0 instances Update, calling inspector.get inside runInDurableObject handler, does work, and having the instance of the inspector instantiated outside (before) the runInDurableObject hook
Olga Silva
Olga Silva3w ago
Hey, it should work the way it is on your example. I have reproduced with a simple similar example and could not face the same problem. There might be some unexpected behavior with your more complex example. But glad it worked by calling the introspector before runInDurableObject and calling get inside of it.

Did you find this page helpful?