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

Jest to test custom checkpoint saver #500

Open
gnaryak opened this issue Sep 20, 2024 · 2 comments
Open

Jest to test custom checkpoint saver #500

gnaryak opened this issue Sep 20, 2024 · 2 comments

Comments

@gnaryak
Copy link

gnaryak commented Sep 20, 2024

Hi - I am writing a custom checkpoint saver to save checkpoints to session storage or local storage in the browser. I would like to write tests in Jest as I develop it, but when I run jest, it tells me:

/Users/me/gh/my-project/node_modules/@langchain/langgraph/web.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from './dist/web.js'
                                                                                      ^^^^^^
    SyntaxError: Unexpected token 'export'

      1 | import type { RunnableConfig } from "@langchain/core/runnables";
    > 2 | import { BaseCheckpointSaver } from "@langchain/langgraph/web";

I am able to write a test outside of jest using Typescript with assert statements, and running it with tsx.

I would prefer to include this test with our suite of Jest tests, and to be able to use Jest.

Any suggestions for being able to test my custom checkpoint saver with Jest?

Also, any advice about creating a checkpoint saver that uses session storage or local storage? I am using the SqliteSaver as a guide.

Thanks!

@jacoblee93
Copy link
Collaborator

Hey @gnaryak! Is your local project in CJS or ESM?

Does it work if you switch from one to the other?

@gnaryak
Copy link
Author

gnaryak commented Sep 21, 2024

Hi @jacoblee93 - ESM. I can't really switch the project. We are committed to ESM. Thanks.

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

2 participants