Coder Social home page Coder Social logo

Comments (10)

johannish avatar johannish commented on July 24, 2024

I'll second this request! A workaround is to create a customRunnerTemplate in which the $sources$ variable is removed, and the app sources are hard-coded, as well as specifying require in sourceIncludes like <include>require.js</include>. Then use require as in your example.

However, because the paths are all hard-coded, this can only be made to work for either the maven build, or the jasmine:bdd plugin (or maybe both if your directory structure matches the default: /src and /spec).

As grignaak mentions, having a $sources$ variable and a separate $specs$ variable would provide a solution to this issue.

from jasmine-maven-plugin.

ebaxt avatar ebaxt commented on July 24, 2024

I'm currently working on adding this feature. It currently supports Require.js, but I've tried to make it easy to add other loaders.

Have a look at this example:

require.js-support

Basically I've refactored out the ScriptRunnerHtmlGenerator into an abstract class, and added a Default implementation and a RequireJs impl that uses different templates. The example above works with both the test goal and the jasmine:bdd.

I'm currently testing the plugin in one of our projects, and if it's stable I'll open a pull request.

from jasmine-maven-plugin.

ebaxt avatar ebaxt commented on July 24, 2024

I've added support for more advanced configuration:

jasmine-webapp-advanced-requirejs

Since there are literally millions of ways to configure scriptloaders like require.js, I think the best way to add this feature is to make it configurable within reason. The example shows how one can wrap dependencies like jQuery, and use the order plugin to evaluate scripts in the correct order. (For example jQuery needs to be resolved before any plugins etc.)

Feedback on where to draw the line when it comes to configurability is welcomed!

from jasmine-maven-plugin.

timowest avatar timowest commented on July 24, 2024

I am getting Mismatched anonymous define() exceptions when running a Backbone + require.js app via jasmine:test.

I am using version 1.0.2-beta-5 of the plugin. Are these issues also fixed in the newer SNAPSHOT releases?

from jasmine-maven-plugin.

ebaxt avatar ebaxt commented on July 24, 2024

@timowest 1.0.2-beta-5 does not support require.js, I've added support in this branch https://github.com/ebaxt/jasmine-maven-plugin/tree/advancedRequirejsExample but haven't opened a pull request yet because of lacking documentation. Also that branch uses a bundled requires.js script, but it makes more sense to bring your own version and let the plugin refere to that (since you need requires.js to load scripts in the first place).

We are using this branch in our system and it's been stable, so once I've resolved the issues mentioned above, I'll open a pull request. In the mean time you can look at this example to get it working: https://github.com/ebaxt/jasmine-maven-plugin/tree/advancedRequirejsExample/src/test/resources/examples/jasmine-webapp-advanced-requirejs

from jasmine-maven-plugin.

timowest avatar timowest commented on July 24, 2024

@ebaxt Thanks, I managed to fix the issue temporarily by wrapping the test execution in the runner HTML via require.

from jasmine-maven-plugin.

ebaxt avatar ebaxt commented on July 24, 2024

Here is the pull request: #50

from jasmine-maven-plugin.

aceontech avatar aceontech commented on July 24, 2024

I've been struggling with this issue myself recently, and I'm glad to see you're working on this :-).

from jasmine-maven-plugin.

kshaff03 avatar kshaff03 commented on July 24, 2024

Thanks for working on this. This would be an immense help for me.

from jasmine-maven-plugin.

searls avatar searls commented on July 24, 2024

I've merged in @ebaxt's pull request. The next release will include the feature.

from jasmine-maven-plugin.

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.