linnovate / mean

The MEAN stack uses Mongo, Express, Angular(6) and Node for simple and scalable fullstack js applications
http://mean.io
12.13k stars 3.45k forks source link

Package testing #827

Closed Zeikko closed 9 years ago

Zeikko commented 9 years ago

Are there any best practices on testing a package?

I have not found any tests in any of the packages in mean.io.

My problem is that the packages are not standalone and depend on the mean and thus are difficult to be automatically tested on their own.

Can you give me an example how to add unit tests and functional tests to a package? Or maybe just an idea how to implement automated testing?

liorkesos commented 9 years ago

Hi jakko. We have discussed the new ed for this as well..all of mean has testing based on karma and mocha. I think the artcilea package should have teata as reference . @fyockm could you look in to this? Lior

On Oct 10, 2014 3:58 PM, "Jaakko Ojalehto" notifications@github.com wrote:

Are there any best practices on adding tests to a package?

I have not found any tests in any of the packages in mean.io.

My problem is that the packages are not standalone and depend on the mean and thus are difficult to be automatically tested on their own.

Can you give me an example how to add unit tests and functional tests to a package? Or maybe just an idea how to implement automated testing?

— Reply to this email directly or view it on GitHub https://github.com/linnovate/mean/issues/827.

fyockm commented 9 years ago

@Zeikko Yes, most core packages do already have tests, namely articles, system, and users. There are interdependencies, but that shouldn't be a big deal.

The package tests are broken down into the public/tests and server/tests directories for client-side and server-side, respectively. Test automation is handled via a grunt task, which runs both sides of tests for all packages (assuming the test specs are in the recommended file structure):

$ grunt test
Zeikko commented 9 years ago

Thanks a lot for your answers.

The core packages have tests but as far as i can see none of the 3rd party packages in mean.io have tests: http://mean.io/#!/packages

My main issue is that the tests can't be run independently. I can't just clone https://github.com/linnovate/mean-user and run grunt test because the package depends on mean. Thus i don't see a simple way to perform automatic testing on a continuous integration server.

Do you have any suggestion how to run tests of a package on a continuous integration server or on a local machine when developing a package independently?

liorkesos commented 9 years ago

This is important - and thanks @Zeikko for focusing on this. We need to set up testing for all packages and to run them off travis our selves. I'm not super proficient in the matter but I'll reach out to the community and try to find someone that can help us set the infrastructure and to introduce the testing.

liorkesos commented 9 years ago

Any insights, best practices or documentation will eventually find themselves here - https://github.com/linnovate/mean/wiki/Testing#packages

Zeikko commented 9 years ago

Thanks for recognizing the problem. I have published a package that illustrates the problem. This package includes tests but there's no way to run them, thus they're not serving their purpose at all. https://github.com/Yleisradio/mean-comscore-api