Unverified Commit 982e880f authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update CNA tests on windows for further investigating (#11779)

parent 0c2a6d8f
...@@ -29,7 +29,7 @@ const runStarter = (...args) => { ...@@ -29,7 +29,7 @@ const runStarter = (...args) => {
describe('create next app', () => { describe('create next app', () => {
beforeAll(async () => { beforeAll(async () => {
jest.setTimeout(1000 * 60 * 3) jest.setTimeout(1000 * 60 * 2)
await fs.mkdirp(cwd) await fs.mkdirp(cwd)
}) })
...@@ -47,18 +47,22 @@ describe('create next app', () => { ...@@ -47,18 +47,22 @@ describe('create next app', () => {
} }
}) })
it('empty directory', async () => { // TODO: investigate why this test stalls on yarn install when
const projectName = 'empty-directory' // stdin is piped instead of inherited on windows
const res = await runStarter(projectName) if (process.platform !== 'win32') {
it('empty directory', async () => {
expect(res.exitCode).toBe(0) const projectName = 'empty-directory'
expect( const res = await runStarter(projectName)
fs.existsSync(path.join(cwd, projectName, 'package.json'))
).toBeTruthy() expect(res.exitCode).toBe(0)
expect( expect(
fs.existsSync(path.join(cwd, projectName, 'pages/index.js')) fs.existsSync(path.join(cwd, projectName, 'package.json'))
).toBeTruthy() ).toBeTruthy()
}) expect(
fs.existsSync(path.join(cwd, projectName, 'pages/index.js'))
).toBeTruthy()
})
}
it('invalid example name', async () => { it('invalid example name', async () => {
const projectName = 'invalid-example-name' const projectName = 'invalid-example-name'
...@@ -163,41 +167,45 @@ describe('create next app', () => { ...@@ -163,41 +167,45 @@ describe('create next app', () => {
).toBeTruthy() ).toBeTruthy()
}) })
it('should allow to manually select an example', async () => { // TODO: investigate why this test stalls on yarn install when
const runExample = (...args) => { // stdin is piped instead of inherited on windows
const res = run(...args) if (process.platform !== 'win32') {
it('should allow to manually select an example', async () => {
function pickExample(data) { const runExample = (...args) => {
if (/hello-world/.test(data.toString())) { const res = run(...args)
res.stdout.removeListener('data', pickExample)
res.stdin.write('\n') function pickExample(data) {
if (/hello-world/.test(data.toString())) {
res.stdout.removeListener('data', pickExample)
res.stdin.write('\n')
}
} }
}
function searchExample(data) { function searchExample(data) {
if (/Pick an example/.test(data.toString())) { if (/Pick an example/.test(data.toString())) {
res.stdout.removeListener('data', searchExample) res.stdout.removeListener('data', searchExample)
res.stdin.write('hello-world') res.stdin.write('hello-world')
res.stdout.on('data', pickExample) res.stdout.on('data', pickExample)
}
} }
}
function selectExample(data) { function selectExample(data) {
if (/Pick a template/.test(data.toString())) { if (/Pick a template/.test(data.toString())) {
res.stdout.removeListener('data', selectExample) res.stdout.removeListener('data', selectExample)
res.stdin.write('\u001b[B\n') // Down key and enter res.stdin.write('\u001b[B\n') // Down key and enter
res.stdout.on('data', searchExample) res.stdout.on('data', searchExample)
}
} }
}
res.stdout.on('data', selectExample) res.stdout.on('data', selectExample)
return res return res
} }
const res = await runExample('no-example') const res = await runExample('no-example')
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
expect(res.stdout).toMatch(/Downloading files for example hello-world/) expect(res.stdout).toMatch(/Downloading files for example hello-world/)
}) })
}
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment