JetClient / jet-client-support

JetClient is an advanced REST API Client plugin for JetBrains IDEs
https://plugins.jetbrains.com/plugin/21173-jetclient
111 stars 0 forks source link

TypeError: Cannot load Module 'chai' when running request with a test (request works fine without Test) #13

Closed inkstain closed 1 year ago

inkstain commented 1 year ago

Describe the Issue

I have some requests that work in http-client in PyCharm that I want to forklift into JetClient

a POST request works fine if the Tests tab is empty, but as soon as I include the following:

jc.globalVariables.setEnv("job_id", jc.response.json().job.id, "Talkdesk")

and rerun the request I get the error. I am trying to parse the response from this request to assign a variable, 'job_id' to use in subsequent requests. The relevant code in the http-client works fine with the following:

> {% client.global.set("job_id", response.body.job.id); %}

I am completely new to JetClient (just subscribed) and have very little experience with PostMan though I have it installed so I might be missing something simple, but this does work on the http-client

Steps to reproduce?

1. take a working POST request with no Test content
2. add `jc.globalVariables.setEnv("job_id", jc.response.json().job.id, "Talkdesk")` as a test
3. request fails to run and generates the provided error

Operating System

Windows

IDE

Pycharm 2023.1 (Professional Edition)

JetClient version

2023.1.7-231

Relevant log output

2023-04-21 11:19:06,808 [13808139]   INFO - #io.jetclient.a - Failed to execute request
TypeError: Cannot load module: 'chai'
    at <js> :program(Unnamed:4:48-62)
    at org.graalvm.polyglot.Context.eval(Context.java:425)
    at io.jetclient.eL.createJsContext(SourceFile:100)
    at io.jetclient.a.executeRequest(SourceFile:247)
    at io.jetclient.a$e.run(SourceFile:209)
    at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:429)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:480)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)

Screenshots, Videos, Additional Context

No response

AntonShuvaev commented 1 year ago

Thanks for reporting the issue. It turns out that test scripts are not working properly on Windows. Will fix it asap.

inkstain commented 1 year ago

Many thanks!, I was fearing the scary alternative, "User error" on my side :D

millsks commented 1 year ago

Thanks! I came across JetClient today too. This looks promising and should be able to ditch Postman and add one more thing we can do from within Postman!

millsks commented 1 year ago

Thanks for reporting the issue. It turns out that test scripts are not working properly on Windows. Will fix it asap.

Just out of curiosity what would the turnaround be for this fix? Looking at this plug-in to use in our environment at work and will have to justify the extra cost. We use the pre-request and test features in Postman so this bug would be a show stopper.

AntonShuvaev commented 1 year ago

The fix is ready. It will be available once approved by the JetBrains team, which can take up to 2 business days.

AntonShuvaev commented 1 year ago

The bug is fixed, please update to version 2023.1.8.