Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test child_process with API route #10872

Merged
merged 1 commit into from Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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