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

Issues with Richtext and vitest #949

Open
1 task done
alvarosabu opened this issue Jan 21, 2025 · 0 comments
Open
1 task done

Issues with Richtext and vitest #949

alvarosabu opened this issue Jan 21, 2025 · 0 comments
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@alvarosabu
Copy link
Contributor

alvarosabu commented Jan 21, 2025

Describe the issue you're facing

User reported :

We are using Storyblok with nuxt and use the renderRichtext function, which is working fine. But, when we use it inside a vitest test, we get the following error and cannot find anything in the docs or elsewhere.
"Please initialize the Storyblok SDK before calling the renderRichText function"
What should we do?
Thanks!
And added some more details on that:
Yes you can. I don't know how it helps in this case, because we really do nothing but calling the function in our test and it fails with said error.

//useRichtext.nuxt.test.ts
import { expect, describe, it } from "vitest";
const testRichtextBlok = {
 type: "doc",
 content: [
   {
     type: "paragraph",
     content: [
       {
         text: "Ziel des Textes",
         type: "text",
         marks: [
           {
             type: "bold",
           },
         ],
       },
     ],
   },
 ],
};
describe("useRichtext", () => {
 it("returns correct template", () => {
   const template = renderRichText(testRichtextBlok);
   expect(template).toBeTruthy();
 });
});

Do you have a hint here, please? I guess that the function doesn't have access to the outside instance of the JS client?

Reproduction

N/A

Steps to reproduce

No response

System Info

Waiting for author

Used Package Manager

npm

Error logs (Optional)

No response

Validations

@alvarosabu alvarosabu added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

1 participant