Are you using the standalone version of postman, or the chrome extension? If you're using the chrome extension, you'll find that pm
is undefined, as stated here
Though perhaps not exactly had in mind, if you are working with the chrome extension, you can defined "testing logic" in a slightly different way via the Tests tab:

The Testing tab allows you to write tests that are automatically run across the response data that returns after your click "Send".
This basically lets you write and execute javascript in Postmans own testing context, allowing you to define some fairly elaborate test logic to verify that your response data returns the expected results:
var contentTypeHeaderExists = responseHeaders.hasOwnProperty("Content-Type");
tests["Has Content-Type"] = contentTypeHeaderExists;
if (contentTypeHeaderExists) {
tests["Content-Type is application/json"] =
responseHeaders["Content-Type"].has("application/json");
}
See this blog post for more information on using the Testing tab - hope this helps you!