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: add test for PR 644 #1

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion lib/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ PDF.prototype.exec = function PdfExec (callback) {
// This is to catch the edge case of having a exit code value of 0 but having no data (exit can be called before io pipes are closed)
error = new Error('html-pdf: Process exited successfully, but no data received')
} else {
// This is to catch the edge case of having a exit code value of 1 but having no error
// This is to catch the edge case of having an exit code value of 1 but having no error
error = new Error('html-pdf: Unknown Error')
}

Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,13 @@ test('allows local file access with localUrlAccess=true', function (t) {
t.assert(count === 5, 'Renders a page 5 pages as the content is present')
})
})

test('phantomjs exit without file generated does not cause crash', function (t) {
t.plan(2)

pdf.create(`<body>foo</body>`, { phantomPath: './test/phantomMock.js' })
.toBuffer(function (error, buffer) {
t.true(error instanceof Error)
t.false(buffer)
})
})
3 changes: 3 additions & 0 deletions test/phantomMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

process.exit(0)