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

renderToString cannot work properly #916

Closed
kazupon opened this issue Aug 11, 2018 · 5 comments
Closed

renderToString cannot work properly #916

kazupon opened this issue Aug 11, 2018 · 5 comments

Comments

@kazupon
Copy link
Member

kazupon commented Aug 11, 2018

Version

1.0.0-beta.24

Reproduction link

https://github.com/kazupon/vue-i18n-extensions/tree/moving

Steps to reproduce

  • git clone [email protected]:kazupon/vue-i18n-extensions.git
  • cd vue-i18n-extensions
  • git branch moving origin/moving
  • git checkout moving
  • yarn
  • yarn test:unit

What is expected?

pass the test in src/__tests__/repro.test.js

What is actually happening?

cannot pass the test in src/__tests__/repro.test.js:

 FAIL  src/__tests__/repro.test.js
  ● cannot work correctly

    expect(string).not.toContain(value)

    Expected string:
      ""
    Not to contain value:
      ""

      18 |     }
      19 |   })
    > 20 |   expect(str).not.toContain('')
         |                   ^
      21 | })
      22 |

      at Object.<anonymous>.it (src/__tests__/repro.test.js:20:19)

I notice renderToString have the critical issue.
See the bellow:
https://github.com/vuejs/vue-test-utils/blob/dev/packages/server-test-utils/src/renderToString.js#L40-L46

renderedString cannot return the correctly string, depending on the implementation of the component.

Vue SSR docs have been saying renderToString(vue-server-renderer) return the Promise.
https://ssr.vuejs.org/api/#renderer-rendertostring

I think renderToStrnig API should be re-designed.

I propose the below the API.

  • renderToString: return the Promise
  • renderToString: provide the callback argument
@eddyerburgh
Copy link
Member

eddyerburgh commented Aug 13, 2018

Yes, we should fix this.

What do you think about handling it through the sync option?

const str = renderToString(TestComponent)

const str = await renderToString(TestComponent, {
  sync: false
})

@kazupon
Copy link
Member Author

kazupon commented Aug 14, 2018

sound good to me. 👍

@eddyerburgh
Copy link
Member

Do you have an example component that won't won't render correctly?

@kazupon
Copy link
Member Author

kazupon commented Sep 23, 2018

Sorry for my late reply.
That's is here
intlify/vue-i18n-extensions@cc85456#diff-0a45b66d57da4b0f77d1825941f54e4b

@jerryni
Copy link

jerryni commented Jan 30, 2019

Same error when the component content is too large to execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants