English 中文(简体)
How can I include utility functions from another file into a Sproutcore unit test file?
原标题:

Lets say I have a few utility functions in file tests/utils/functions.js. I would like to use these functions from several unit test files.

However, I m not able to use them as the Sproutcore build system does not include any external files into the html page used to run the unit tests. Only application code and the code from the unit tests to be run are included.

So is it possible to somehow include Javascript files to be used in unit test files in Sproutcore?

I could add the functions.js file into some other directory inside my application to be able to use them. However, this is not what I want to do as the utility functions are useless in final production build and would only make my application larger.

最佳回答

I solved this by creating frameworks/testing/functions.js under my Sproutcore project. Then I changed the following line in Buildfile

config :all, :required => :sproutcore

to:

config :all, :required => :sproutcore, :test_required => [ testing ]

Now the utility functions get correctly included when unit tests are being done but they don t end up to the production build.

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签