feat: added testing for new#212
Conversation
There was a problem hiding this comment.
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 |
Souvikns
left a comment
There was a problem hiding this comment.
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.
Souvikns
left a comment
There was a problem hiding this comment.
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.
| 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.
Souvikns
left a comment
There was a problem hiding this comment.
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!
|
Souvikns
left a comment
There was a problem hiding this comment.
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 <lpgornicki@gmail.com> Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com> * 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 <abir.pal899@gmail.com> Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com> Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com> Co-authored-by: asyncapi-bot <61865014+asyncapi-bot@users.noreply.github.com> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Samriddhi <Agrawalsamriddhi83@gmail.com> Co-authored-by: asyncapi-bot <bot+chan@asyncapi.io>











Description
new.test.tsTodo
startStudio.test.tsRelated issue(s)
Fixes #106