Skip to content

Why vitest seams to not wait the end of async functions? And why an observer can help with that? #6647

Discussion options

You must be logged in to vote

Haven't looked entirely but getDataAvailable is not returning a promise:

    // Component Data
    async getDataAvailable() {
...
        } else {
+           return window.fetch(MyCustomeHTMLClass.apiEndPoint).then((response) => {
-           window.fetch(MyCustomeHTMLClass.apiEndPoint).then((response) => {
                if (!response.ok) {
                    throw new Error(`HTTP error! Status: ${response.status}`);
                }
                return response.json();
...
        }
    }

which would make await element.getDataAvailable() to not await anything, so the behavior you're seeing is a normal javascript behavior.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by matheus-hatzlhoffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants