Skip to content

fix(sdk): support async function in insomnia.test#8243

Merged
ihexxa merged 8 commits into
developfrom
fix/sdk/async-test
Dec 23, 2024
Merged

fix(sdk): support async function in insomnia.test#8243
ihexxa merged 8 commits into
developfrom
fix/sdk/async-test

Conversation

@ihexxa

@ihexxa ihexxa commented Dec 11, 2024

Copy link
Copy Markdown
Contributor

Changes

  • Monitor all tests in the script and suspending the script execution until all sync tests or async tests are finished or rejected
  • Test it

image

Ref: INS-4765

@ihexxa ihexxa self-assigned this Dec 11, 2024
@ihexxa
ihexxa marked this pull request as draft December 12, 2024 11:30
@ihexxa
ihexxa force-pushed the fix/sdk/async-test branch from 7c88059 to 790d51a Compare December 17, 2024 07:14
@ihexxa
ihexxa requested a review from a team December 17, 2024 07:47
@ihexxa
ihexxa marked this pull request as ready for review December 17, 2024 07:48
@cwangsmv
cwangsmv self-requested a review December 20, 2024 02:17

@cwangsmv cwangsmv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, only a minor issue which could fix in later releases

function translateTestHandlers(script: string): string {
const replacedTests = script.replace(/insomnia\.test\(/g, 'await insomnia.test(');
return replacedTests.replace(/insomnia\.test\.skip\(/g, 'await insomnia.test.skip(');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A minor issue here:
If user has already input await, it will translate the script to

await await insomnia.test('xxx', () => {})

It's fine for me since double await could execute as expected, maybe we can enhance in the future

@ihexxa
ihexxa enabled auto-merge (squash) December 23, 2024 03:26
@ihexxa
ihexxa force-pushed the fix/sdk/async-test branch from b0f06e1 to 3e9aceb Compare December 23, 2024 03:26
@ihexxa
ihexxa merged commit de29164 into develop Dec 23, 2024
@ihexxa
ihexxa deleted the fix/sdk/async-test branch December 23, 2024 03:39
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