thunderclient / thunder-client-support

Thunder Client is a lightweight Rest API Client Extension for VS Code.
https://www.thunderclient.com
Other
3.61k stars 126 forks source link

tc.loadModule() not working for faker in Pre-Request script #1498

Closed ColinSowul closed 5 months ago

ColinSowul commented 5 months ago

Describe the bug I've been attempting to use faker-js in order to generate test data for some APIs I want to test, but there seems to be an issue when Thunder Client attempts to load the module. Currently, the only content of my script is simply copy & pasted from what is shown in the documentation

When I attempt to send the request, I get the following error: Error in Pre Request Script: - Cannot destructure property 'faker' of '(intermediate value)' as it is undefined.

To Reproduce

Expected behavior The Pre-Request script executes successfully, and populates a randomly-generated name into the "firstName" environment variable

Platform:

Are you using the free version/paid version/trial: Paid

rangav commented 5 months ago

@ColinSowul There is problem loading latest versions.

version 8.0.0 is working

var { faker } = await tc.loadModule("@faker-js/faker", "8.0.0");

console.log(faker.person.firstName());
ColinSowul commented 5 months ago

That worked, thanks for the quick response!