diff --git a/test/fixtures/basic/pages/async-props.js b/test/fixtures/basic/pages/async-props.js new file mode 100644 index 00000000..2401e133 --- /dev/null +++ b/test/fixtures/basic/pages/async-props.js @@ -0,0 +1,18 @@ +import React from 'react' + +export default class AsyncProps extends React.Component { + static async getInitialProps () { + return await AsyncProps.fetchData() + } + + static fetchData () { + const p = new Promise(resolve => { + setTimeout(() => resolve({ name: 'Diego Milito' }), 10) + }) + return p + } + + render () { + return
{this.props.name}
+ } +} diff --git a/test/index.js b/test/index.js index d90a7844..596d9db6 100644 --- a/test/index.js +++ b/test/index.js @@ -19,7 +19,7 @@ test(async t => { }) test(async t => { - const html = await (render('/stateful')) + const html = await render('/stateful') t.true(html.includes('The answer is 42
Diego Milito
')) +}) + function render (url, ctx) { return _render(url, ctx, { dir, staticMarkup: true }) }