未验证 提交 21e4c3f0 编写于 作者: J James George 提交者: GitHub

tests(create-next-app): leverage execa (#19008)

Leverage [execa](https://github.com/sindresorhus/execa) for writing to `stdin`.
上级 60951199
......@@ -187,31 +187,20 @@ describe('create next app', () => {
if (process.platform !== 'win32') {
it('should fall back to default template', async () => {
await usingTempDir(async (cwd) => {
const runExample = (...args) => {
const res = run(args, { cwd })
function fallbackToTemplate(data) {
if (
/Do you want to use the default template instead/.test(
data.toString()
)
) {
res.stdout.removeListener('data', fallbackToTemplate)
res.stdin.write('\n')
}
const projectName = 'fail-example'
const res = await run(
[projectName, '--example', '__internal-testing-retry'],
{
cwd,
input: '\n',
}
res.stdout.on('data', fallbackToTemplate)
return res
}
const res = await runExample(
'fail-example',
'--example',
'__internal-testing-retry'
)
expect(res.exitCode).toBe(0)
const files = ['package.json', 'pages/index.js', '.gitignore']
files.forEach((file) =>
expect(fs.existsSync(path.join(cwd, projectName, file))).toBeTruthy()
)
})
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册