jeudi 15 septembre 2016

How to configure jasmine tests for complex app that uses webpack with multiple entry points?

I work on a complex web application that consists of several websites. These websites work as sub-domains and are placed in the same root directory.

All frontend-related things (js, css, less, fonts, images, ...) are placed in one directory called ui. Overall, it looks like this:

root
|- site1
|- siteN
 ` ui
    |- vendors...
    |- common...
    |- app1
    |   |- section1...
    |   |   ` subsection...
    |   |      |- someName1.js
    |   |      |- someName.less
    |   |      |- someTpl.html
    |   |      |- someNameN.js
    |   |       ` specs
    |   |           ` someSpec.js
    |   |- section2...
    |    ` sectionN...
     ` appN...

Some of these files belong only to one of the sites and some are common for several sites. I've already managed to build bundles for each of the sites using multiple configs and entry points (like it is stated here http://ift.tt/2cbkZtM and here http://ift.tt/1A4YOR2). So, now I have the following structure:

root
|- site1
|- siteN
|- ui
 ` bundles
    |- site1
    |   |- bundle1.js
    |   |- bundle1.css
    |   |- bundleN.js
    |   |- bundleN.css
    |   |- common.js
    |   |- common.css
    |    ` ...
     `- siteN...

It looks like these bundles are actually working. But now I have to set up tests. According to historical reasons some of the code is written in pure JS, some relies on jQuery, some uses AngularJS... Before webpack all this code was passed to jasmine (it is used as a Grunt plugin) at the same time. But now it is impossible to do that because require function is not available there and only a part of the code base is actually present on one site (so, some tests will fail because there are no sources to test). It would be nice to have an ability to test each site on it's own. It is easy to determine what source files should be tested (they are specified in entry sections of webpack config), but I need some way to determine what test files should be used for each site.

How can I determine what spec files should be used to test a set of entry points (for example, bundles related to site1)?

I thought about mapping specs to bundles or requiring specs in entry points. But I'm not sure whether these solutions are good or not.

Aucun commentaire:

Enregistrer un commentaire