Skip to content

test: add test for start studio - #227

Closed
Samridhi-98 wants to merge 10 commits into
asyncapi:masterfrom
Samridhi-98:feat/start-studio
Closed

Samridhi-98 wants to merge 10 commits into
asyncapi:masterfrom
Samridhi-98:feat/start-studio

Conversation

@Samridhi-98

Copy link
Copy Markdown
Contributor

Description

  • Added test for start studio

Related issue(s)

Fixes #106

@Samridhi-98

Copy link
Copy Markdown
Contributor Author

@Souvikns please review my PR 🙂

@Souvikns

Copy link
Copy Markdown
Member

I just checked it in my machine and even though the test is passing the WebSocket server is not closing which leaves the test command running forever.

Comment thread test/commands/studio.test.ts Resolved
@Samridhi-98

Samridhi-98 commented Feb 12, 2022 •

Copy link
Copy Markdown
Contributor Author

./test/specification.yml

I am not able to access the WebSocket object wsServer inside my test file. Do I need to add a flag for close command in start studio or is there any other way to do so?

@Samridhi-98
Samridhi-98 requested a review from Souvikns February 19, 2022 07:14
@Samridhi-98

Copy link
Copy Markdown
Contributor Author

@Souvikns please review my PR :)

@magicmatatjahu

Copy link
Copy Markdown
Member

If you add tests you should change the prefix for PR from feat to chore, because you don't introduce new features :)

@Samridhi-98 Samridhi-98 changed the title feat: added test for start studio chore: added test for start studio Feb 28, 2022
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@derberg derberg changed the title chore: added test for start studio test: add test for start studio May 24, 2022
@derberg

derberg commented May 24, 2022

Copy link
Copy Markdown
Member

@Samridhi-98 do you plan to continue on this one, the PR test is failing

@Samridhi-98

Copy link
Copy Markdown
Contributor Author

@Samridhi-98 do you plan to continue on this one, the PR test is failing

I tried fixing it but unable to do so. Need help for the same 🙂

@derberg

derberg commented Jun 7, 2022

Copy link
Copy Markdown
Member

@Souvikns since you were active here before, can you have a look 🙏🏼

@sonarqubecloud

sonarqubecloud Bot commented Jun 7, 2022

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Souvikns

Souvikns commented Jun 8, 2022

Copy link
Copy Markdown
Member

@Samridhi-98

import { expect, test } from '@oclif/test';

describe('start', () => { 
  test
    .stdout()
    .stderr()
    .command(['start:studio', '--file=./test/specification.yml', '--port=8080'])
    .it('runs studio', ctx => {
      expect(ctx.stdout).to.contain('Studio is running at http://localhost:8080?liveServer=8080');
      setTimeout(() => {
        process.exit();
      }, 5000);
    });
});

Just doing this the test cases pass but the studio also starts on the browser, which I don't know if it's ideal in gh runner, can't find any way to exit the process in a controlled manner.

One way could be to extract the server object

server.listen(port, () => {
test it and then kill the process, using oclif's testing library which is capturing the stdout messages, it's very hard to terminate the server after we are done testing.

@derberg do we absolutely need this test?

@derberg

derberg commented Jun 21, 2022

Copy link
Copy Markdown
Member

@derberg

derberg commented Jul 5, 2022

Copy link
Copy Markdown
Member

@Souvikns @Samridhi-98 did you have a chance to look at my proposal?

@Souvikns

Souvikns commented Jul 5, 2022

Copy link
Copy Markdown
Member

How about adding here https://github.com/asyncapi/cli/blob/master/src/models/Studio.ts#L53 listener for stop, and on stop terminate the server. Then in the test, after testing connect to the server and emit stop 🤔 some example here https://stackoverflow.com/questions/23258421/how-to-stop-app-that-node-js-express-npm-start

@Samridhi-98 you want to give it a try?

@github-actions

github-actions Bot commented Nov 3, 2022

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions Bot added the stale label Nov 3, 2022
@derberg

derberg commented Nov 17, 2022

Copy link
Copy Markdown
Member

@Samridhi-98 hey, do you plan to continue with this one?

@Samridhi-98

Copy link
Copy Markdown
Contributor Author

@Samridhi-98 hey, do you plan to continue with this one?

No, I'll open new one. Shall I close this PR?

@github-actions github-actions Bot removed the stale label Nov 18, 2022
@derberg

derberg commented Nov 21, 2022

Copy link
Copy Markdown
Member

@Samridhi-98 yup, that would be the best. Just open new one once you are ready

@Samridhi-98 Samridhi-98 closed this Dec 4, 2022
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.

Add tests for "new" and "start studio" commands

4 participants