Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

separation of unit testing not working  #294

Closed

Description

@jquerygeek

Hello

I wanted to keep unit testing files in separate folder out of app/, I wanted to keep the outside of app/ as spec/unit/app.spec.js, but its giving error as


/angular2-project/spec/unit/app.component.spec.js".
    Chrome 54.0.2840 (Mac OS X 10.10.5): Executed 0 of 0 ERROR (0.006 secs / 0 secs)

Updated my karma.conf as
var testBase = 'spec/unit/';

can you advice please.

Activity

  1. wardbell commented on Nov 30, 2016

    @wardbell
    Contributor

    That was a problem! karma-test-shim couldn't handle more than one base path containing spec files.

    I've updated karma-test-shim and karma.config accordingly. I made your use case work with the following changes

    // karma-test-shim
    ...
    // builtPaths: root paths for output ("built") files
    // get from karma.config.js, then prefix with '/base/' (default is 'app/')
    var builtPaths = (__karma__.config.builtPaths || ['app/'])
                     .map(function(p) { return '/base/'+p;});
    ...
    // Is a "built" file if is JavaScript file in one of the "built" folders
    function isBuiltFile(path) {
      return isJsFile(path) &&
             builtPaths.reduce(function(keep, bp) {
               return keep || (path.substr(0, bp.length) === bp);
             }, false);
    }
    ...
    // karma.config.js
      var appBase    = 'app/';       // transpiled app JS and map files
      var appSrcBase = 'app/';       // app source TS files
      var appAssets  = 'base/app/'; // component assets fetched by Angular's compiler
    
      var testingBase    = 'spec/unit/'; // transpiled test JS and map files
      var testingSrcBase = 'spec/unit/'; // test source TS files
    ...
    
        client: {
          builtPaths: [appSrcBase, testingBase], // add more spec base paths as needed
          clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
    ...
    

    Attached the working project in the following zip
    issue-294-example.zip

    The fundamental changes to karma-test-shim and karma.config is now in master as v.0.2.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions