开发者

How do I configure paths to my javascript files in the Jasmine / Maven autogenerated ManualSpecRunner.html?

开发者 https://www.devze.com 2023-03-03 10:44 出处:网络
I think the question says most of it.I have an autogenerated ManualSpecRunner.html file as created by maven / jasmine plug-in and I\'ve got it to put itself into the deployable .war by using:

I think the question says most of it. I have an autogenerated ManualSpecRunner.html file as created by maven / jasmine plug-in and I've got it to put itself into the deployable .war by using:

<jasmineTargetDir>${basedir}/pathForMyWebapp</jasmineTargetDir>

However, all the links to js files within the ManualSpecR开发者_JAVA技巧unner.html are hard coded file:/// references - this is a bit mental, I want them to just be the relative paths to the files that are also in the webapp i.e.

Currently it gives me this path:

file:///home/username/code/HEAD/pathForMyWebapp/js/yui.js

whereas I need it to have the far more simple

/pathForMyWebapp/js/yui.js

I have tried changing two other variables in the maven script, but neither seems to have the desired effect, neither of these configuration options do what I need, the second having seemingly no effect:

<jsSrcDir>/pathForMyWebapp</jsSrcDir>

nor

<jsTestSrcDir>/pathForMyWebapp</jsTestSrcDir>

I've looked through the documentation but think I must be missing something (also, more notes on various config params listed in https://github.com/searls/jasmine-maven-plugin/blob/master/src/main/java/com/github/searls/jasmine/AbstractJasmineMojo.java are meant to do would be helpful so I can work out if I'm doing it wrong or if it's not possible!)

Any suggestions?

[p.s. I've changed some of the path names as they've got sensitive info in them, so please ignore their oddness!]


I think I understand the source of your confusion. It looks like you're trying to direct the target of the jasmine-maven-plugin to a directory inside your project's packaged *.war file so that you can run your specs against the code after it's deployed to a server, is that correct?

Unfortunately, the plugin wasn't designed with that use in mind. The jasmineTargetDir directory is usually left at its default value of target/jasmine and wasn't intended to be bundled with your application (it's analogous to the target/surefire-reports generated by maven-surefire-plugin for Java unit tests). So the reason that the script tags in ManualSpecRunner.html point to invalid locations is because that file is generated in order to be run from the local filesystem in a browser from the workstation that's building the project (to facilitate TDD).

All of that to say, if I'm reading your intention right, I think it'd be a cool feature to build a third spec runner that could be deployed with the app and executed remotely. (Especially if the project's Jasmine specs are functional/integration as opposed to isolated unit tests.) Unfortunately that's not something the project does yet.

I'm afraid that for now, if you needed to bundle the jasmine tests and execute them on the deployed server, you would need to copy ManualSpecRunner.html and jasmine into your src/main/webapp, fix the script tag references, and then manually maintain it as files are added and removed.

Make sense?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号