Skip to content

renderToString cannot work properly #916

Closed
@kazupon

Description

@kazupon

Version

1.0.0-beta.24

Reproduction link

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

Steps to reproduce

  • git clone git@github.com: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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions