Git Product home page Git Product logo

Comments (9)

Stabzs avatar Stabzs commented on July 17, 2024

Are you loading `'node_modules/traceur/bin/traceur-runtime.js', // Required by PhantomJS2, otherwise it shouts ReferenceError: Can't find variable: require' before attempting to load angular2-toaster? Also, are you mapping it at all in your systemjs configuration?

from angular2-toaster.

mwoodsmall avatar mwoodsmall commented on July 17, 2024

Yes I am doing both of those... my suspicion is that maybe my mapping is wrong. I'll play around with that some more.

from angular2-toaster.

mwoodsmall avatar mwoodsmall commented on July 17, 2024

here is my System.config in my test.main.js

System.config({
  baseURL: '/base/',
  defaultJSExtensions: true,
  paths: {
    'angular2/*': 'node_modules/angular2/*.js',
    'rxjs/*': 'node_modules/rxjs/*.js'
  },
  map: {
    'angular2-toaster': 'node_modules/angular2-toaster'
  }
});

That looks right doesn't it?

from angular2-toaster.

Stabzs avatar Stabzs commented on July 17, 2024

Yes, the mapping looks correct.

In hindsight, I do remember having a lot of issues implementing the karma test runner. Note that the https://github.com/Stabzs/Angular2-Toaster/blob/master/karma-test-shim.js used is a bit different from what is used in the seed. If you follow it, something like

Promise.all([
    System.import('angular2/src/platform/browser/browser_adapter'),
    System.import('angular2/platform/testing/browser'),
    System.import('angular2/testing')
    System.import('angular2-toaster')
]).

might be necessary.

In this case, I suspect that angular2-toaster is loading before traceur is loaded to properly polyfill export. Have you verified loading order?

from angular2-toaster.

mwoodsmall avatar mwoodsmall commented on July 17, 2024

I haven't verified loading order yet. Your suspicion sounds reasonable though. I'll take a look into that.

from angular2-toaster.

Stabzs avatar Stabzs commented on July 17, 2024

If there's anything I can do to help track it down, please feel free to let me know :)

from angular2-toaster.

mwoodsmall avatar mwoodsmall commented on July 17, 2024

@Stabzs I got things working.... not super happy about what I ended up with, tho, I will post again tonight with more details

from angular2-toaster.

mwoodsmall avatar mwoodsmall commented on July 17, 2024

to get my tests running, I had to add

{ pattern: 'node_modules/angular2-toaster/angular2-toaster.js', included: false },
{ pattern: 'node_modules/angular2-toaster/lib/*.js', included: false },

to the files section of my karma configuration file.

Then, in test-main.js I had to modify System.config to add path for angular2-toastr and map it.

System.config({
  baseURL: '/base/',
  defaultJSExtensions: true,
  paths: {
    'angular2/*': 'node_modules/angular2/*.js',
    'rxjs/*': 'node_modules/rxjs/*.js',
    'angular2-toaster/*': 'node_modules/angular2-toaster/lib/*.js'
  },
  map: {
    'angular2-toaster': 'node_modules/angular2-toaster'
  }
});

Then in the same file, I had to import it using System.import

Promise.all([
  System.import('angular2/src/platform/browser/browser_adapter'),
  System.import('angular2/platform/testing/browser'),
  System.import('angular2/testing'),
  System.import('angular2-toaster/angular2-toaster')
])

from angular2-toaster.

Stabzs avatar Stabzs commented on July 17, 2024

Thanks for the details and perseverance on this issue.

I'm not certain if there's a better way to structure this or if the library could make this type of testing easier. I'm open to suggestions but I'll be closing the issue for now since I don't think it's necessarily something the library is doing incorrectly.

from angular2-toaster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.