HTTP Response Handler - Support for mutiple http response handler scripts for a http request

Answered

Greetings!

Currently I am using the response handler scripts to test my http response object. I am including the script using the following syntax:
> my-script.js

But I have several requests that all have some common assertions. The idea was to extract the common assertions in a common file. Something like this:
In my-script.js:

import {commonAssertions} from 'common'; // where 'common' is the JS file containing all the common assertions

I have tried various methods to include this common javacsript file in my response handler scripts. But it is not supported.

I have 2 queries here:
1) Is there a feature request for support of ES6 for http handlers?
2) Is there any other way to achieve the above (having more than 1 javascript http handlers for a http request), till https://youtrack.jetbrains.com/issue/WI-44851?project=WI is implemented?

 

2
2 comments

You can use load('/an/absolute/path/to/an/import.js') to include an import into the current script.

Unfortunately, there seems to be no way to refer to the import with a relative path. We've tried to get the handler script path and use it, but this code

f = new java.io.File("handler-script.js");
print(f.getAbsolutePath());

returns /PhpStormInstallationDirectory/bin/handler-script.js, which seems to be a design flaw.

If using the absolute path would make you happy enough then fine, if it would not - please submit a request on our tracker for this design flaw to be fixed: https://youtrack.jetbrains.com/newIssue?project=WI

0
Avatar
Permanently deleted user

Thank you for the reply. I have submitted the following the request :

https://youtrack.jetbrains.com/issue/CPP-16718 to address this issue.

0

Please sign in to leave a comment.