Phantomjs does not wait script running in angularjs - hudson

I trying to use phantomjs call angularjs test on hudson server. But it's seem like phantomjs shutdown itself before angularjs done theirs test. Does it has some method or way to make phantomjs wait until angular test script done before graping result.

Maybe you can check QUnit runner for PhantomJS example, which comes with phantomjs. In function called waitFor. But I don't know if this example will help you with angularjs. In case of QUnit the main idea is to check for div with id = 'qunit-testresult' using setInterval function to determine if QUnit has completed.
NOTE
Don't forget asynchronous nature of JavaScript and PhantomJS :)

Related

How can I add debug functions that I can call from Chrome Debugger Console to a Create React App?

I created an app with Create React App.
How can I add global debug functions (e.g. resetDatabase()) that I can call from Chromes Debug Console (or some other way)?
You can attach the function to the global window object, or some namespaced object.
Then in the console you can run it with:
window.resetDatabase();
Here’s a link to a relevant post about accessing the global context through the componentWillMount callback.
How to declare a global variable in React?
Refer this site -:
IT gives you the complete guide for that or if you face any issue feel free to ask
https://developers.google.com/web/tools/chrome-devtools/console/

ClojureScript + boot: make non-CLJSJS libs available to test code?

When using boot for ClojureScript projects, how does one make external non-CLJSJS JavaScript libraries available to test code (vs application code)?
Application code can get access when it's included on the same HTML page as the library.
(With leiningen + figwheel, the test code ran in the same context as the application code -- on my index.html page -- so the test code was aware of the third party js library.)
Is there a similar page context in boot for test code? Or is there a way to conj something like ["resources/third-party/library.js"] onto a source or resource path, such that unit tests can refer to the same library that application code does?
When I run boot auto-test it says #object[ReferenceError ReferenceError: Can't find variable: CodeMirror]. CodeMirror is the third party library in my case. My unit tests need a CodeMirror instance so they can .setValue, then call a bunch of CodeMirror methods to tell the instance what to do, then verify the instance's new value and cursor position. I'm testing whether my ClojureScript comes up with the right calls to CodeMirror in order to have the intended effects.
I've been able to use the latest CLJSJS version of CodeMirror but it doesn't pass my unit tests whereas the most recent non-CLJSJS version directly from CodeMirror does pass. So I'm guessing I need the latest CodeMirror, which isn't yet offered via CLJSJS yet.
Here's part of my build.boot file:
(deftask testing []
(set-env! :source-paths #(conj % "test/cljs"))
identity)
(deftask test []
(comp (testing)
(test-cljs :js-env :phantom
:exit? true)))
(deftask auto-test []
(comp (testing)
(watch)
(test-cljs :js-env :phantom)))

Using Delphi component under C++ Builder makes calls to a wrong function

I'm trying to use Graphics32 package. Graphics32 was compiled and installed without any issue.
When I try to execute (debug) following code under C++ Builder XE3
TBitmap32* bmp = new TBitmap32();
bmp->LoadFromFile("d:\\sample.bmp");//This calls SaveToStream instead of LoadFromFile
...
it calls another member function SaveToStream which I can trace into and step while debugging until AV rises.
I have never encountered such behavior before.
Is there any compiler directive I'm missing or some workaround to make proper function call?
Update: I use the Graphics32 source from SVN. Everything works good if I use code prior to revision 2122.

Can an embedded cocos2d-js app call back out to c++?

I'm researching the possibility of using cocos2d-js by embedding it as a view inside an existing iOS app. In order to make this work, I'm going to need 2-way communication between cocos2d and the surrounding application.
After some initial investigation, I have determined that it is possible to call in to cocos using ScriptingCore:
ScriptingCore* sc = ScriptingCore::getInstance();
jsval outVal;
sc->evalString("function()", &outVal);
My question, then, is around doing the reverse. It is possible to (e.g. in response to user input) call back out of cocos2d-js to C++? Ideally, there would be a way to register a callback with ScriptingCore which could be invoked from JavaScript.
I believe it can be done, but I have not tried myself, nor can I find a good and concise example.
All I can do is point you at SuperSuraccoon's Bluetooth example and it's git page, which apparently does both ways communication between C++ and JS code.

Observable Command and Unit tests with Rx RTM

I have ported my code to the RTM version of both WinRT and Rx. I use ReactiveUI in my ViewModels. Before porting the code my unit tests were running without problem but now I got a strange behavior.
Here the test:
var sut = new MyViewModel();
myViewModel.MyCommand.Execute(null) //ReactiveAsyncCommand
Assert.AreEqaul(0, sut.Collection.Count)
If I debug the test step by step, the assertion is not failing, but using the test runner it's failing...
The Collection asserted is modified by a method subscribing to the command:
MyCommand.RegisterAsyncTask(_ => DoWork())
.ObserveOn(SynchronizationContext.Current)
.Subscribe(MethodModifyingCollection);
The code was working before moving it to the RTM. I tried also to remove the ObserveOn and add an await Task.Delay() before the Assert without success.
Steven's got the rightish answer, but there are a few RxUI specific things missing. This is definitely related to scheduling in a test runner, but the reason is that the WinRT version of ReactiveUI can't detect properly whether it's in a test runner at the moment.
The dumb workaround for now is to set this at the top of all your tests:
RxApp.DeferredScheduler = Scheduler.CurrentThread;
Do not use the TestScheduler for every test, it's overkill and actually isn't compatible with certain kinds of testing. TestScheduler is good for tests where you're simulating time passing.
Your problem is that MSTest unit tests have a default SynchronizationContext. So ObserveOn and ReactiveAsyncCommand will marshal to the thread pool instead of to the WPF context. This causes a race condition.
Your first and best option is the Rx TestScheduler.
Another option is to await some completion signal (and ensure your test method is async Task, not async void).
Otherwise, if you just need a SynchronizationContext, you can use AsyncContext from my AsyncEx library to execute the tests within your own SynchronizationContext.
Finally, if you have any code that directly uses Dispatcher instead of SynchronizationContext, you can use WpfContext from the Async CTP download.