MCPcopy
hub / github.com/vuejs/core / testRender

Function testRender

packages/server-renderer/__tests__/render.spec.ts:68–1251  ·  view source on GitHub ↗
(type: string, render: typeof renderToString)

Source from the content-addressed store, hash-verified

66testRender(`pipeToNodeWritable`, pipeToWritable)
67
68function testRender(type: string, render: typeof renderToString) {
69 describe(`ssr: ${type}`, () => {
70 test('should apply app context', async () => {
71 const app = createApp({
72 render() {
73 const Foo = resolveComponent('foo') as ComponentOptions
74 return h(Foo)
75 },
76 })
77 app.component('foo', {
78 render: () => h('div', 'foo'),
79 })
80 const html = await render(app)
81 expect(html).toBe(`<div>foo</div>`)
82 })
83
84 test('warnings should be suppressed by app.config.warnHandler', async () => {
85 const app = createApp({
86 render() {
87 return h('div', this.foo)
88 },
89 })
90 app.config.warnHandler = vi.fn()
91 await render(app)
92 expect('not defined on instance').not.toHaveBeenWarned()
93 expect(app.config.warnHandler).toHaveBeenCalledTimes(1)
94 })
95
96 describe('components', () => {
97 test('vnode components', async () => {
98 expect(
99 await render(
100 createApp({
101 data() {
102 return { msg: 'hello' }
103 },
104 render(this: any) {
105 return h('div', this.msg)
106 },
107 }),
108 ),
109 ).toBe(`<div>hello</div>`)
110 })
111
112 test('option components returning render from setup', async () => {
113 expect(
114 await render(
115 createApp({
116 setup() {
117 const msg = ref('hello')
118 return () => h('div', msg.value)
119 },
120 }),
121 ),
122 ).toBe(`<div>hello</div>`)
123 })
124
125 test('setup components returning render from setup', async () => {

Callers 1

render.spec.tsFile · 0.85

Calls 15

escapeHtmlFunction · 0.90
renderToStringFunction · 0.90
hFunction · 0.85
defineComponentFunction · 0.85
createCommentVNodeFunction · 0.85
createTextVNodeFunction · 0.85
createStaticVNodeFunction · 0.85
renderSlotFunction · 0.85
withCtxFunction · 0.85
getCurrentInstanceFunction · 0.85
fn2Function · 0.85
watchEffectFunction · 0.85

Tested by

no test coverage detected