bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Improvement of the testing strategy

Open redaemn opened this issue 13 years ago • 6 comments

Hello everybody.

I just forked the repo and started examining the code and running the tests; I noticed one thing: the testacular configuration load all the JS files together and run all the tests. Wouldn't it be better if every module was tested on its own?

I mean, there should be one test run that loads the JS sources and tests of a single module and its dependencies, runs the tests, collects the results and then start a new test run for the next module. In this way we're sure that every module is tested in isolation and a feature implemented in one module cannot interfere with a different module and make some test become green (or red) when they shouldn't.

This seems a good enhancement to me, also since one of the objectives of the project "just grab the code for the directives you need" (cit.) and so every module should be guaranteed to be able to be run on its own.

I was thinking of doing it in this way:

  • create a specific testacular.conf.js file for every module, this should include only JS sources, tests and dependencies of the module
  • having the grunt test task take the name of a module as a parameter so that it will run only the tests for that specific module
  • passing all as parameter should cycle over every module and execute every module's tests on their own

redaemn avatar Mar 14 '13 22:03 redaemn

As an example of this issue, I started writing an iefix module to try and make the directives run correctly also on IE8; just as a start, I noticed that many directives used the Array.indexOf() method that is not supported by IE8, so I wrote in the .config() section of the module a polyfill for the method.

There are 2 modules that uses the indexOf()method: accordionand carousel. I modified the accordion module to have iefix as a dependency, run the tests and suddenly the tests for carousel turned green too. This wasn't right, those tests worked only because the accordion module was also loaded and it consequently loaded the iefix module.

On the other and, if iefix is set as a dependency of the carousel module, all seems to work fine, its tests turn green and the accordion's one don't. This happens just because modules are loaded by testacular in alphabetical order an so this time, when accordion is tested, carousel(and therefore iefix) hasn't been loaded yet.

In my opinion these kind of behaviors shouldn't happen.

redaemn avatar Mar 14 '13 23:03 redaemn

@redaemn Appreciate you taking time to suggest the project layout change but I'm not in favor of this (at least at this point in time) for the following reasons:

  • in practice it is not that simple as there are dependencies between directives and things are changing as we speak
  • proposed changes would slow down tests

What you are proposing is not bad but I don't think it is practical at the moment.

Regarding indexOf issue (and IE8 compatibility) - we had a similar discussion in https://github.com/angular-ui/bootstrap/issues/194. My take at this would be not to penalize people using modern browsers and I think that we should relay on existing, conditionally loaded pollyfils to tackle this problem.

IE8 is definitively on our roadmap so I really appreciate you looking into this and would be filling to help if needed. But we should discuss the direction to take before and as I've said above I'm not fan of maintaining a shim for IE8 as part of this project.

@angular-ui/bootstrap any other thoughts on this?

pkozlowski-opensource avatar Mar 15 '13 18:03 pkozlowski-opensource

@pkozlowski-opensource I agree. At this point in time I think it could become a management headache. I also think as much as possible we should rely on existing polyfills; browser compatibility can be a nightmare, so we should keep an eye toward the future and focus on standards. Plus, non-compliant browsers are self-limiting.

Good suggestion, but not practical - at least not yet.

joshdmiller avatar Mar 15 '13 18:03 joshdmiller

@redaemn based on the discussion above I'm going to close this issue.

As I've said IE8 is still on our radar and we would appreciate any help. Fell free to jump on any IE8-specific issues or discuss more on the mailing list ([email protected])

pkozlowski-opensource avatar Mar 15 '13 19:03 pkozlowski-opensource

@pkozlowski-opensource ok, so can I continue to takle the IE8 issue? (apart from the indexOfproblem, of course :) I saw an issue #8 opened about that... or there's some more pressing task I can do? I'd really like to contribute...

edit: something like affix or scrollspy I read on your plus page...

redaemn avatar Mar 15 '13 21:03 redaemn

@redaemn helping us with IE8 issues would be absolutely awesome! As I've said there is no shortage of work and I believe that to support IE8 correctly we need to do some global tweaks in the project and then work with individual directives.

Globally the following needs to be done:

  • select a recommended shim for JavaScript (indexOf etc.) and conditionally include it in the demo page
  • modify the build to generate a shim for HTML tags (https://github.com/angular-ui/bootstrap/issues/93) or prepare the shim "by hand"

After the above is done, individual directives need to be tested with IE8. I suspect that we will have some fun with tooltips and popovers as the positioning logic might be tricky to get right across all the browsers.

Affix and scrollspy are nice to have but we are not crazy about them atm. For now I'm more focused on merging existing PRs and fixing reported bugs. If you think that you are going to use a particular directive have a look at the PRs / issues associated with it - this is always very good way of starting with the codebase.

Otherwise hit us on the mailing list ([email protected]) to discuss more.

pkozlowski-opensource avatar Mar 17 '13 10:03 pkozlowski-opensource