-
Notifications
You must be signed in to change notification settings - Fork 42
Setup testing #8
Comments
Hi, What kind of setup are we talking about? I use Jasmine for running my tests, and while I'm still learning to write tests, I have put some practice into it, and I'm looking to improve. Could you elaborate on the kind of setup you want? |
Maybe use Jest for jsx test? It builts on top of the Jasmine test framework. |
@AJ-Santos the basic idea is to cover the whole codebase with tests. I've already included the right dependencies in package.json.
For an example of what I mean you can take a look at the Ghost's functional tests here After that we can try writing unit tests for services, repositories, config and so on. I've also created the testing.js configuration file inside the config folder. Every testing specific configuration should live in it. Some time ago I wrote some test for another node app, you can take some inspiration if you will, here's the link. @jessy1092 I'm a noob at Jest and have no experience in React testing, any help here would be awesome. |
@vesparny I was thinking that it might be better to start by testing the business logic and testing the endpoints later because running those tests from the beginning will eventually make tests take too long to run. If we start with the more basic business logic we'll get more tests done that run quickly, and test for more use cases that won't reach the endpoints. |
@AJ-Santos you are right, better start from the beginning. Any thoughts on how to structure files and folder? |
I'm not familiar with Mocha so my suggestion would be to use this structure, just because I don't know a better way. If you prefer a different structure then let me know. |
I created in another project the basic structure for testing the app with mocha. I reused this structure for Morpheus, if you look at the gulp file you'll find the test task.
If you run it, one test is executed.
So basically the structure is already in place, you just need to write the first test 👍 |
I gave it a shot but I have to admit that creating tests for this project is out of my scope. |
Jest can write jsx in test, so it is more friendly to test react component. Mocha also can test react component, but just more complicated. React test with mocha Do we need two system for testing? One for business logic, one for components? I don't mind to write the mocha to test react components. 😄 |
@AJ-Santos thanks for you effort, let me know which task do you want to take. 👍 @jessy1092 we can use mocha to test what is not React, and Jest for testing the template.
Morpheus will provide a command line interface which will install a local blog. So the problem now is: How can we test the template within an isolated scope? |
Yap, It's mean components would also be separated in several npm modules. Right? It's a very good idea. I like that. In Jest, we can write the test follow the component and write in the componets' folder. One test file for one component. That can easily separate in the future. like:
We also can separate components in difference folder first if already know it would be separated in the future. maybe like:
|
For now I'd leave The theme folder only one level deep, no need for subfolders. |
@jessy1092 any news here? |
I just trace the code. I'll write the react test in the weekend. :) |
No description provided.
The text was updated successfully, but these errors were encountered: