I have a Collection that has POST requests in it.
This collections needs bearer token for auth.
The Pre-request script and Tests assertion is written at Collection level.
Problem: The collection works fine when ran in Postman, but when I run it in Azure… it throws “Syntax Error Unexpected token at test-script inside…”. And none of the assertions written at collection level is validated as indicated by 0 in report.
How can I resolve Unexpected token issue and have the assertions run. Thanks.
PRE-Request Script:
postman.setEnvironmentVariable("guid", genHexString(32));
const parse =require('csv-parse/lib/sync');
const holiday = parse(pm.environment.get("holiday"),{
});
Tests:
const responseData = pm.response.json();
const csv_data = pm.environment.get("test_data");
const parse = require('csv-parse/lib/sync');
const csv_parsed_json_data = parse(csv_data, {
});
pm.test("Response has a body", () => {
pm.response.to.be.withBody;
});
pm.test("response body is json", () => {
pm.response.to.have.jsonBody()
});
Error message in Azure
# failure detail
01. SyntaxError
Unexpected token .
at test-script
inside "Set library"
02. SyntaxError
Unexpected token .
at test-script
inside "Obtain Token"
03. SyntaxError
Unexpected token .
at test-script
inside "Introspection"
04. SyntaxError
Unexpected token .
at test-script
inside "test case for so and so "