Skip to content

Commit

Permalink
Test child_process with API route (#10872)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Mar 6, 2020
1 parent 764edc5 commit 178f45b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/integration/api-support/pages/api/child-process.js
@@ -0,0 +1,8 @@
import { execSync } from 'child_process'

export default (req, res) => {
const output = execSync('echo "hi"')
.toString()
.trim()
res.end(output)
}
5 changes: 5 additions & 0 deletions test/integration/api-support/test/index.test.js
Expand Up @@ -322,6 +322,11 @@ function runTests(dev = false) {
expect(data).toEqual({ post: 'post-1', id: '1' })
})

it('should work with child_process correctly', async () => {
const data = await renderViaHTTP(appPort, '/api/child-process')
expect(data).toBe('hi')
})

if (dev) {
it('should compile only server code in development', async () => {
await fetchViaHTTP(appPort, '/')
Expand Down

0 comments on commit 178f45b

Please sign in to comment.