Skip to content

Added ES6 feature support to NodeJS Unirest codegen#197

Merged
shreys7 merged 2 commits intopostmanlabs:developfrom
sastava007:ES6-NodeJS-Unirest
Mar 11, 2020
Merged

Added ES6 feature support to NodeJS Unirest codegen#197
shreys7 merged 2 commits intopostmanlabs:developfrom
sastava007:ES6-NodeJS-Unirest

Conversation

@sastava007
Copy link
Contributor

What this PR does
It allows the user to generate the code snippet for NodeJS Unirest in the ES6 format.
This is in response to issue #115 requested by one of the users.

Changes you made

  • Registered a new parameter ES6_enabled in options() which allows the user to toggle between whether codegen generates snippet with ES6 features or not.

  • By default ES6_enabled is set to false

  • Also added the newly created option parameter in structure.test.js file to register it as a valid option id.

  • Added unit tests to verify the generated snippets in snippet.test.js

  • Added a new mocha test suite to verify that the generated snippet is runnable in newman.test.js.

  • Updated the readme.md file with new option parameter.

Screenshot/ CodeSnippet
Not required

Test Configuration:

  • Added a unit test to check the snippet generated

  • Added a new block of mocha test inside the main suite to verify that the snippet produced is runnable.

Follow up
Not required

Thanks for contributing! ❤️

@sastava007
Copy link
Contributor Author

@umeshp7 @shreys7
Please review!

snippetArray = snippet.split('\n');
expect(snippetArray[0]).to.equal('const unirest = require(\'unirest\');');
expect(snippetArray).to.include(`const req = unirest('${mainCollection.item[0].request.method}', ` +
`'${mainCollection.item[0].request.url.raw}')`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add an expect for .end arrow function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shreys7 Actually, initially I tried for that but don't know somehow I was getting error maybe because of some extra space.
Let me try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shreys7 I have updated, please have a look.

@shreys7 shreys7 merged commit 0b514e1 into postmanlabs:develop Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants