dart test dart:html without loading dartium - dart

Is there any way to test a code with dart:html imported on it, without dartium being triggered.
I want to test HttpRequest to a JSON data and expected it to display it on terminal, and dart editor wants to open dartium EVERYTIME, which i think unnecessary.

Dartium contains the browser hosted Dart VM, which the relevant browser DOM bindings. When you run code that needs a browser DOM, such as dart:html, you will get Dartium running.
However, you can also use DumpRenderTree - which is a headless browser (ie, produces output to the console).
Take a look at these post for more about DumpRenderTree and Dart:
http://work.j832.com/2013/01/headless-browser-testing-dart.html
http://docs.drone.io/dart.html
http://japhr.blogspot.co.uk/2013/01/regression-testing-of-browser-dart-code.html

Related

Vaadin / load reactjs build

We develop a reactjs application which works fine, but one of our customer wants to load this application inside their vaadin environment.
I thought sending them the reactjs build will be enough but for some reason they cannot load it : they use vaadin 14 and try to load the build script via #JsModule annotation and put a vaadin div component with the correct id (in order for reactjs to bootstrap it) but they say they hava this error :
Uncaught Error: Minified React error #200; visit
https://reactjs.org/docs/error-decoder.html?invariant=200 for the full
message or use the non-minified dev environment for full errors and
additional helpful warnings
I dont know what's is going on here.
Thanks
If you follow that link, you'll see that the full error message is:
Target container is not a DOM element.
It seems likely that when the script ran, the target Div did not exist yet. Using #JsModule means that the Vaadin application will include that module into its Javascript build, and run it as soon as the Vaadin application bootstraps in the browser. At that point in time there isn't anything related to the Vaadin application in the DOM yet.
One thing you could try is to change your script to expose a function (for example using a window global) to render the React application into the Div, rather than have the script render the React application immediately when the script runs. On the Vaadin side, your customer could then call that function as soon as the target Div has been added to the DOM, for example using executeJs in the components onAttach method.

Unknown Format in feature testing rails capybara

I am writing capybara tests. There is a link I have in the view. When I click over the link that links open a pop-up js warning. I have configured Js. in capybara by using phantomjs and petergiest gem.
Without the requested information it's impossible to give an exact answer, but the error you are seeing means the app is requesting a non-JS response (probably HTML). This could be occurring for a couple of reasons
You're not actually running the test with a JS supporting driver. I don't see any js metadata on your scenarios so depending on how you've configured Capybara/RSpec this could by your issue. To confirm, swap from Poltergeist to using Selenium with Chrome or Firefox (non-headless while trying to debug) so you can see if the browser actually starts
You have a JS error preventing JS from running so a normal request is being made instead of XHR. This could be because you actually have a bug in your JS or because you're using Poltergeist/PhantomJS which is massively out of date in JS/CSS support. To test this, swap to using Selenium with Chrome or Firefox and look in the developer console.
Your link isn't correctly configured to make an ajax request - This is impossible to tell without the HTML of the link
Additionally, neither of the tests shown in your image are actually asserting/expecting anything so it's very unclear what exactly you're trying to test.

Dart server works in Chrome and Firefox, but not in Dartium

I’m new to Dart and I’m going through the server tutorial (https://dart-lang.github.io/server/codelab/). For some reason, the final application is working fine when accessed from the Chrome browser (Windows, Version 57.0.2987.133 (64-bit)) and Firefox (47.0.2), but not in Dartium (=Chromium, Version 45.0.2454.104). When requested from Dartium, the server provides the html page, but it is static. The Dart code behind it (e.g. web/piratebadge.dart) doesn’t seem to execute at all.
However, if I run a simple client-based application (like https://webdev.dartlang.org/codelabs/angular_components) and serve it using pub serve, it works fine both in Dartium and in Chrome.
Any ideas what might be wrong?

Debugging javascript with Plunker

I am just starting out with Plunker, and I want to use Firefox or Chrome developer tools to debug javascript. It looks like the javascript files get cached the first time I open them in the debugger panel. How can I get the panel to refresh after I make changes to the javascript? (I've tried developer tools in Chrome and Firefox, and I've tried Firebug too)
in chrome:
open the developer tools
open the file you want to debug: Ctrl+O and type app.js or similar
set a breakpoint
the only tricky part is the 2nd step, since the file is in a very obscure location, fortunately Ctrl+O comes handy

Dart without Dart-Editor: Refreshing

I'm trying to program in Dart but without the Dart-Editor. It works fine so far but its really annoying and slow to always call pub build after making a change to either html/css or dart code.
As far as I remember when launching the app with Dart-Editor you just have to refresh the page.
Is it possible to get this working without the editor?
Thanks!
You can use pub serve which is similar to the webserver integrated in the Darteditor.
If you are using Dartium as browser you can add --no-dart2js so pub serve doesn`t generate JavaScript (which is slow) but directly serves Dart which Dartium can process directly.
For other browsers it's of course convenient to use the integrated dart2js conversion.

Resources