[GH-ISSUE #65] Add Tests #25

Closed
opened 2026-03-16 12:49:52 +03:00 by kerem · 15 comments
Owner

Originally created by @Amoroth on GitHub (Aug 26, 2019).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/65

Originally assigned to: @Amoroth on GitHub.

Is your feature request related to a problem? Please describe.
I just found the project and I think it's great, but suddenly it stopped working. I noticed that a few minuter ago a pull request was merged, so I think that, it may have something to do with it. It says in console: "TypeError: Cannot read property 'className' of undefined".

Describe the solution you'd like
I noticed that the project lacks tests, maybe it would be better to add them to avoid mistakes in the future?

Describe alternatives you've considered
None.

Additional context
None.

Originally created by @Amoroth on GitHub (Aug 26, 2019). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/65 Originally assigned to: @Amoroth on GitHub. **Is your feature request related to a problem? Please describe.** I just found the project and I think it's great, but suddenly it stopped working. I noticed that a few minuter ago a pull request was merged, so I think that, it may have something to do with it. It says in console: "TypeError: Cannot read property 'className' of undefined". **Describe the solution you'd like** I noticed that the project lacks tests, maybe it would be better to add them to avoid mistakes in the future? **Describe alternatives you've considered** None. **Additional context** None.
kerem 2026-03-16 12:49:52 +03:00
Author
Owner

@NBTX commented on GitHub (Aug 26, 2019):

Agreed, we definitely need some proper unit tests. Nuxt seems to prefer Ava for testing.
https://nuxtjs.org/examples/testing

<!-- gh-comment-id:524833627 --> @NBTX commented on GitHub (Aug 26, 2019): Agreed, we definitely need some proper unit tests. Nuxt seems to prefer Ava for testing. https://nuxtjs.org/examples/testing
Author
Owner

@Amoroth commented on GitHub (Aug 26, 2019):

Makes sense, Ava seems to be fast with async tests but they use it only for e2e testing, I don't know if it can be used for unit tests. We could also use Jest which is officialy supported by vue but seems to be a bit harder to setup with Nuxt. But if we don't need unit tests, then Ava seems to me like a good choice.

<!-- gh-comment-id:524845159 --> @Amoroth commented on GitHub (Aug 26, 2019): Makes sense, Ava seems to be fast with async tests but they use it only for e2e testing, I don't know if it can be used for unit tests. We could also use Jest which is officialy supported by vue but seems to be a bit harder to setup with Nuxt. But if we don't need unit tests, then Ava seems to me like a good choice.
Author
Owner

@liyasthomas commented on GitHub (Aug 26, 2019):

We we need these badly. I think Jest can also be integrated with Nuxt with a catch (https://stackoverflow.com/questions/52493255/integration-testing-with-nuxt-and-jest) but AVA seems to have out of the box support to Nuxt for E2E and unit testing.

<!-- gh-comment-id:524848458 --> @liyasthomas commented on GitHub (Aug 26, 2019): We we need these badly. I think Jest can also be integrated with Nuxt with a catch (https://stackoverflow.com/questions/52493255/integration-testing-with-nuxt-and-jest) but AVA seems to have out of the box support to Nuxt for E2E and unit testing.
Author
Owner

@Amoroth commented on GitHub (Aug 26, 2019):

So I've played around with testing in Ava and all the examples are made with e2e testing in mind, which involves setting up a server, and making requests to it. As it is all asynchrous, Ava seems to be doing a good job. I noticed aswell, that the project is set up as an spa, so a server should not be needed.

I also tried Jest, to see how it would work and integrating it into Nuxt is not that bad, it is simply used like in any normal Vue app. It only requires 3 packages, Jest itself, @vue/test-utils and vue-jest, but the last one has to be version 4.0.0-0 at least. It is supported by Nuxt itself, though there are no examples for that, in create-nuxt-app cli, there is an option to enable Jest or Ava as a testing framework.

Also, for unit tests, it would be best to use Vue Test Utils and according to this https://github.com/eddyerburgh/vue-unit-test-perf-comparison, there are performance considirations with Ava. It was made 2 years ago, so it might be fixed already, but when I was checking them, Jest seemed to be faster. There might be a problem with Jest though, that supposedly it doesn't trigger asyncData(). I haven't checked it myself, but apparently, it can be fixed by calling it manually.

<!-- gh-comment-id:524923012 --> @Amoroth commented on GitHub (Aug 26, 2019): So I've played around with testing in Ava and all the examples are made with e2e testing in mind, which involves setting up a server, and making requests to it. As it is all asynchrous, Ava seems to be doing a good job. I noticed aswell, that the project is set up as an spa, so a server should not be needed. I also tried Jest, to see how it would work and integrating it into Nuxt is not that bad, it is simply used like in any normal Vue app. It only requires 3 packages, Jest itself, @vue/test-utils and vue-jest, but the last one has to be version 4.0.0-0 at least. It is supported by Nuxt itself, though there are no examples for that, in create-nuxt-app cli, there is an option to enable Jest or Ava as a testing framework. Also, for unit tests, it would be best to use Vue Test Utils and according to this https://github.com/eddyerburgh/vue-unit-test-perf-comparison, there are performance considirations with Ava. It was made 2 years ago, so it might be fixed already, but when I was checking them, Jest seemed to be faster. There might be a problem with Jest though, that supposedly it doesn't trigger asyncData(). I haven't checked it myself, but apparently, it can be fixed by calling it manually.
Author
Owner

@NBTX commented on GitHub (Aug 27, 2019):

@Amoroth Have you checked the code/scripts that create-nuxt-app runs for setting up either test libraries? The Nuxt team is pretty 'on it' and it's possible they've patched these kinds of issues in their setup process.

<!-- gh-comment-id:525515872 --> @NBTX commented on GitHub (Aug 27, 2019): @Amoroth Have you checked the code/scripts that `create-nuxt-app` runs for setting up either test libraries? The Nuxt team is pretty 'on it' and it's possible they've patched these kinds of issues in their setup process.
Author
Owner

@Amoroth commented on GitHub (Aug 28, 2019):

@NBTX I did, I think both work well but Ava has a bit more dependencies and a setup file to actually be able to parse vue files. Jest just seems a bit simpler for me, I wrote a few tests already to check how it works with nuxt and so far, it is really simple. From what I have found, Ava seems to excel at async tests while Jest is great with running tests in parallel, which is great for ui testing.

<!-- gh-comment-id:525826728 --> @Amoroth commented on GitHub (Aug 28, 2019): @NBTX I did, I think both work well but Ava has a bit more dependencies and a setup file to actually be able to parse vue files. Jest just seems a bit simpler for me, I wrote a few tests already to check how it works with nuxt and so far, it is really simple. From what I have found, Ava seems to excel at async tests while Jest is great with running tests in parallel, which is great for ui testing.
Author
Owner

@yubathom commented on GitHub (Aug 30, 2019):

I made a setup and created some e2e tests with cypress Im a personal dev purpose branch. If you're considering cypress I can do a PR with this setting.

<!-- gh-comment-id:526633531 --> @yubathom commented on GitHub (Aug 30, 2019): I made a setup and created some e2e tests with cypress Im a personal [dev purpose branch](https://github.com/yubathom/postwoman/blob/object-queries/tests/e2e/integration/url_queries.js). If you're considering cypress I can do a PR with this setting.
Author
Owner

@liyasthomas commented on GitHub (Aug 30, 2019):

@yubathom I personally haven't used Cypress before. But if it does the job we can consider using it. If anybody else is working on Ava or Jest they can continue that.

<!-- gh-comment-id:526636549 --> @liyasthomas commented on GitHub (Aug 30, 2019): @yubathom I personally haven't used Cypress before. But if it does the job we can consider using it. If anybody else is working on Ava or Jest they can continue that.
Author
Owner

@NBTX commented on GitHub (Aug 30, 2019):

I'm not particularly familiar with any testing libraries in particular, so I don't really mind which we use. I just took a look at a unit test you linked and it looks fine to me.

TL;DR: I'm happy with Cypress.

<!-- gh-comment-id:526667008 --> @NBTX commented on GitHub (Aug 30, 2019): I'm not particularly familiar with any testing libraries in particular, so I don't really mind which we use. I just took a look at a unit test you linked and it looks fine to me. TL;DR: I'm happy with Cypress.
Author
Owner

@Amoroth commented on GitHub (Aug 30, 2019):

I don't know anything about Cypress but it looks like an e2e testing framework specifically. I don't think that is bad at all but doing unit tests in it may be harder as Vue Test Utils doesn't support it, it may work though, I don't know. Cypress, I think, works by spinning up whole local server and runs tests against it, while Jest works in isolated enviroments that just simulate real browsers. I didn't do any e2e tests yet, but I have worked on some unit tests already in Jest, you can look at how it looks like, setup and structure, here. Now, I would like to point out, that I am no professional and the test cases may be awful, but I guess it's a start.

<!-- gh-comment-id:526701148 --> @Amoroth commented on GitHub (Aug 30, 2019): I don't know anything about Cypress but it looks like an e2e testing framework specifically. I don't think that is bad at all but doing unit tests in it may be harder as Vue Test Utils doesn't support it, it may work though, I don't know. Cypress, I think, works by spinning up whole local server and runs tests against it, while Jest works in isolated enviroments that just simulate real browsers. I didn't do any e2e tests yet, but I have worked on some unit tests already in Jest, you can look at how it looks like, setup and structure, [here](https://github.com/Amoroth/postwoman/tree/65-add-tests). Now, I would like to point out, that I am no professional and the test cases may be awful, but I guess it's a start.
Author
Owner

@yubathom commented on GitHub (Aug 30, 2019):

Right. I'll do a PR with cypress then.

<!-- gh-comment-id:526705093 --> @yubathom commented on GitHub (Aug 30, 2019): Right. I'll do a PR with cypress then.
Author
Owner

@liyasthomas commented on GitHub (Sep 6, 2019):

I think now its the time for next version release 🚀

Remaining v1.0 milestone tasks:

  • #93 Import request from cURL
  • #62 Fast URL entry
  • #33 Code highlight on response body : PR #76
  • #29 Ability to store/share/create collections : #72 Enable shareable requests with parameters in url queries
  • #2 #128 CORS
<!-- gh-comment-id:528666949 --> @liyasthomas commented on GitHub (Sep 6, 2019): I think now its the time for next version release 🚀 Remaining v1.0 milestone tasks: - #93 Import request from cURL - #62 Fast URL entry - #33 Code highlight on response body : PR #76 - #29 Ability to store/share/create collections : #72 Enable shareable requests with parameters in url queries - #2 #128 CORS
Author
Owner

@liyasthomas commented on GitHub (Sep 15, 2019):

@Amoroth @yubathom is there any updates on this issue? I hope stable release v1.0 will be at the end of this week and it would be great to run some tests!!

<!-- gh-comment-id:531567492 --> @liyasthomas commented on GitHub (Sep 15, 2019): @Amoroth @yubathom is there any updates on this issue? I hope stable release v1.0 will be at the end of this week and it would be great to run some tests!!
Author
Owner

@yubathom commented on GitHub (Sep 15, 2019):

@liyasthomas the setup is almost done. I will send a PR tomorrow.

<!-- gh-comment-id:531593751 --> @yubathom commented on GitHub (Sep 15, 2019): @liyasthomas the setup is almost done. I will send a PR tomorrow.
Author
Owner

@liyasthomas commented on GitHub (Oct 6, 2019):

#181 resolves this hence closing.

<!-- gh-comment-id:538700486 --> @liyasthomas commented on GitHub (Oct 6, 2019): #181 resolves this hence closing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#25
No description provided.