Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk): change insomnia.test mechanism to improve the nested test cases #8388

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ihexxa
Copy link
Contributor

@ihexxa ihexxa commented Feb 20, 2025

Changes

  • Change the mechanism of insomnia.test to improve the nested test cases
  • Support await insomnia.test
  • Enable autocomplete for insomnia.test and insomnia.expect
  • Added smoke tests

Add sync or async cases in script to test it:

          insomnia.test('asyncHappyTestInFunc', () => {
            insomnia.expect(200).to.eql(200);
          });

          insomnia.test('asyncHappyTestInFunc', async () => {
            insomnia.expect(200).to.eql(200);
          });

INS-5005

@ihexxa ihexxa self-assigned this Feb 20, 2025
@ihexxa ihexxa changed the title fix: change insomnia.test mechanism to improve the nested test cases fix(sdk): change insomnia.test mechanism to improve the nested test cases Feb 20, 2025
@ihexxa ihexxa requested a review from a team February 20, 2025 06:34
Copy link
Contributor

@yaoweiprc yaoweiprc left a comment

Choose a reason for hiding this comment

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

Could there be any compatibility issues since the function passed to test() is executed asynchronously now?

@ihexxa ihexxa force-pushed the fix/sdk/nested-test branch from c94a94c to 9f8593f Compare February 24, 2025 02:24
@ihexxa
Copy link
Contributor Author

ihexxa commented Feb 24, 2025

Could there be any compatibility issues since the function passed to test() is executed asynchronously now?

@yaoweiprc This is a good question, theoretically, for those who pass function without async, as those tests are still executed synchronously, so the behavior should not change. for those who pass function with async, originally their code returned an error and didn't work, then the currently patch should work.

@cwangsmv
Copy link
Contributor

Nit: Why don't we expose insomnia.test insomnia.expect method in snippets?
I see there's logic making test/expect as private property and do not expose them in getRequestScriptSnippets method while postman has hints for pm.test pm.exepct.

@ihexxa
Copy link
Contributor Author

ihexxa commented Feb 24, 2025

Nit: Why don't we expose insomnia.test insomnia.expect method in snippets? I see there's logic making test/expect as private property and do not expose them in getRequestScriptSnippets method while postman has hints for pm.test pm.exepct.

@cwangsmv Good catch, it just tries to wrap _expect and _test so that we can add some manual validation, let me tinker it a bit to see if I can expose them.

@ihexxa ihexxa force-pushed the fix/sdk/nested-test branch from 9f8593f to 2172810 Compare February 25, 2025 02:40
@ihexxa
Copy link
Contributor Author

ihexxa commented Feb 25, 2025

Updated PR with following changes:

  • Support await insomnia.test
  • Enable autocomplete for insomnia.expect and insomnia.test
  • Added a test

@ihexxa ihexxa force-pushed the fix/sdk/nested-test branch from 2172810 to 69fa119 Compare February 25, 2025 06:12
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.

3 participants