-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
feat: added testing for new #212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
@fmvilas please review my PR 🙂 |
Adding @Souvikns as I'm not a maintainer of this repo :) |
@Samridhi-98 firstly thanks for opening PR we really appreciate it 👍🏻 The new command generates specification files. It is using inquirer to prompt for inputs. In the test environment, it is waiting for prompt input but not getting it. Due to this, you see the Here you have to test for |
@Souvikns I have implemented the changes but still getting a bunch of errors, Also I have doubts related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue you see is because of the prompt testing, I tried finding some examples with inquirer but wasn't able to find anything.
I tried running the test in uninteractive mode it works fine
describe('new', () => {
test
.stderr()
.stdout()
.do(() => {
testHelper.createAsyncapiFile('specification.yaml', 'default-example.yaml');
})
.command(['new', '--no-tty', '-n=specification.yaml'])
.it('runs new command', ctx => {
expect(ctx.stdout).to.contain('specification.yaml');
});
});
only you can make sure that specification.yaml
does not exist when you are running the test.
I am still trying to figure out how the prompt testing works and I will let you know when I get something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this is interesting, the tests are running in my local dev environment, but looking into the logs I think it is not waiting for the command to finish and thus is failing and some times it is causing problem for other tests as well.
runs new command:
AssertionError: expected '' to include 'specification.yaml'
at Context.<anonymous> (test/commands/new.test.ts:9:29)
at Object.run (node_modules/fancy-test/lib/base.js:44:38)
at Context.run (node_modules/fancy-test/lib/base.js:68:36)
test/commands/new.test.ts
Outdated
.stdout() | ||
.command(['new', '--no-tty', '-n=specification.yaml']) | ||
.it('runs new command', (ctx, done) => { | ||
expect(ctx.stdout).to.contain('specification.yaml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(ctx.stdout).to.contain('specification.yaml'); | |
expect(ctx.stderr).to.equals(''); | |
expect(ctx.stdout).contains('specification.yaml'); |
This is working for me, you can try this once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try what I suggested once, and if it does not work let me know I will open a PR to your branch 👍🏻
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I think it is ready to be merged 🚀
/rtm |
@all-contributors please add @Samridhi-98 for tests |
I've put up a pull request to add @Samridhi-98! 🎉 |
🎉 This PR is included in version 0.15.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* docs: fix missing toc (asyncapi#230) * feat: add global specification watcher (asyncapi#220) Co-authored-by: Lukasz Gornicki <[email protected]> Co-authored-by: Maciej Urbańczyk <[email protected]> * chore(release): v0.14.0 (asyncapi#237) * docs: add imabp as a contributor for code (asyncapi#239) Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> * fix: update @asyncapi/studio to 0.10.0 version (asyncapi#241) * chore(release): v0.14.1 (asyncapi#242) * feat: added testing for new (asyncapi#212) * docs: add Samridhi-98 as a contributor for test (asyncapi#248) * ci: update global workflows (asyncapi#246) * chore(release): v0.15.0 (asyncapi#249) * feat: migrate to latest oclif version (asyncapi#203) * chore: update bot name from codeowners file (asyncapi#247) * ci: update global workflows (asyncapi#250) * Create test.yml * Update test.yml * Update test.yml * Update test.yml * Update test.yml Co-authored-by: Abir <[email protected]> Co-authored-by: Lukasz Gornicki <[email protected]> Co-authored-by: Maciej Urbańczyk <[email protected]> Co-authored-by: asyncapi-bot <[email protected]> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Samriddhi <[email protected]> Co-authored-by: asyncapi-bot <[email protected]>
* docs: fix missing toc (asyncapi#230) * feat: add global specification watcher (asyncapi#220) Co-authored-by: Lukasz Gornicki <[email protected]> Co-authored-by: Maciej Urbańczyk <[email protected]> * chore(release): v0.14.0 (asyncapi#237) * docs: add imabp as a contributor for code (asyncapi#239) Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> * fix: update @asyncapi/studio to 0.10.0 version (asyncapi#241) * chore(release): v0.14.1 (asyncapi#242) * feat: added testing for new (asyncapi#212) * docs: add Samridhi-98 as a contributor for test (asyncapi#248) * ci: update global workflows (asyncapi#246) * chore(release): v0.15.0 (asyncapi#249) * feat: migrate to latest oclif version (asyncapi#203) * chore: update bot name from codeowners file (asyncapi#247) * ci: update global workflows (asyncapi#250) * Create test.yml * Update test.yml * Update test.yml * Update test.yml * Update test.yml * Update test.yml Co-authored-by: Abir <[email protected]> Co-authored-by: Lukasz Gornicki <[email protected]> Co-authored-by: Maciej Urbańczyk <[email protected]> Co-authored-by: asyncapi-bot <[email protected]> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Samriddhi <[email protected]> Co-authored-by: asyncapi-bot <[email protected]>
Description
new.test.ts
Todo
startStudio.test.ts
Related issue(s)
Fixes #106