Suppose I have a module that depends on a method from an annotated service:
import {method} from './generated/MyService.js';
export class MyController {
async myAction() {
return await method();
}
}
When doing frontend unit tests for that module, I want to be able to import it a Node.js environment and stub the dependencies. Currently, this is blocked because:
importing the unit imports the generated client, there is no straightforward way to stub ES module dependencies to prevent that;
the generated client imports the default client;
the default client instance is created upon import;
the client constructor attempts to restore the refresh token from localStorage synchronously, which throws.
Suggested solution: postpone restoring the refresh token to the first call instead of doing that right in the client constructor. That should enable stubbing the method before it calls browser APIs.
Suppose I have a module that depends on a method from an annotated service:
When doing frontend unit tests for that module, I want to be able to import it a Node.js environment and stub the dependencies. Currently, this is blocked because:
localStorage
synchronously, which throws.Suggested solution: postpone restoring the refresh token to the first
call
instead of doing that right in the client constructor. That should enable stubbing the method before it calls browser APIs.