Dart Mockito: spies? - unit-testing

I don't see any mentions of spies support in Mockito for dart in the latest versions.
In the changelog:
2.0.0-dev #
Remove export of spy and any dart:mirrors based API from mockito.dart. Users may import as package:mockito/mirrors.dart going forward.
Deprecated mockito_no_mirrors.dart; replace with mockito.dart.
Require Dart SDK >=1.21.0 <2.0.0 to use generic methods.
0.11.1 #
Move the reflection-based spy code into a private source file. Now package:mockito/mockito.dart includes this reflection-based API, and a new package:mockito/mockito_no_mirrors.dart doesn't require mirrors.
0.10.0 #
Added support for spy.
Is there any support for spies in the context of unit-testing in Dart?

Related

Does uninstalling Custom Module Builder Extension affects the custom created modules

We are using vTiger CRM with its Extension Pack from VTExpers, Inc.
We used the Custom Module Builder Extension to Custom Modules Several times, now we want to Uinstall the extension.
My Question is:
What will happen to the Custom Created Modules, which have been created through this Extension, will they disappear as well, or they will remain Active in the CRM?
I want to keep the Custom Modules and remove (uninstall) the Extension it self.
They remain in your crm but your custom modules will not work after uninstalling Custom Module Builder
Simply modify YourCustomModuleName_Module_Model class and remove isActive method from class. you can find this class in the following path:
modules/YourCustomModuleName/models/Module.php
yes, created modules will be there
The modules will be there, beware as VT Experts uses ION Cube to encrypt most of their extensions so you have no idea what the code is doing.

import node js module in ember js framework

I am trying to import a simple node js module into Ember js. I followed the quick start at https://guides.emberjs.com/v3.8.0/getting-started/quick-start/ and got the People List working.
Then I added the simple upper-case module using npm install upper-case and added app.import('node_modules/upper-case/upper-case.js'); to ember-cli-build.js as mentioned in https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/.
After that, I opened scientists.js and added import to upper-case as follows:
import Route from '#ember/routing/route';
//import uc from 'upper-case';
export default Route.extend({
model() {
var arr = new Array();
arr[0] = 'Marie Curie'; // uc('Marie Curie');
arr[1] = 'Mae Jemison';
arr[2] = 'Albert Hofmann';
return arr;
}
});
If I remove the comments, it shows me a blank screen. If I use 'Marie Curie'.toUpperCase() it works, but I want to be able to import such node modules. How can I achieve this?
I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.
PS: I could make upper-case work in other JS frameworks such as React and Vue, so the module itself doesn't have any issues.
if you install ember-auto-import, you'll be able to use any npm package like how the particular npm package's documentation says to use it (provided the particular npm package is configured correctly on build).
https://github.com/ef4/ember-auto-import
This'll be a default soon (and is recommended over using app.import)
The reason ember-auto-import is recommended over app.import is because there are ~ 5 different module formats JS can exist in, and you need to worry about those when using app.import. ember-auto-import, powered by webpack, abstracts all that away from you.
fwiw, JS has .toUpperCase() built in: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
so you don't need that particular module.
Edit
I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.
did you get any errors with this?

Ember v. 2.x: watch vendor folder

I'm developing an Ember-JS application with a lot of JavaScript that performs of all kind of UX and styling tasks.
Because these tasks fall out of the scope the MVC-logic, I've put them into modules that I put in the vendor map.
Putting them into the Vendor folder doesn't mean I'm done tweaking these files, but to test them, I'm required to re-start the ember-server over and over again.
How can I make Ember watch these JS-files in my vendor folder and re-compile them when I change them?
The following page answers for Ember v. 1, but doesn't apply to Ember 2.0: https://discuss.emberjs.com/t/solved-watch-addon-directory-for-changes/6410/4
I also tried creating an addon, but ember (cli) answers with: “You cannot use the addon command inside an ember-cli project.”
It took me a while to connect all the pieces of information scattered over internet, but using #Lux 's anwers, this is what I found out.
1) Using the ember-cli, I generate a 'utility' (hence the utils folder):
ember g util grid-layout
This gives you a JS-file “app/utils/grid-layout.js” template to fill in. In my case, it was a matter of…
2) copy-paste the body of the function I created earlier, into the body of the function that ember-cli came up with:
export default function gridLayout(tree) {
…
return tree
}
3) Importing the function in the controller, in my case controllers/index.js. I found different examples on how to do this, with and without curly braces and using different paths to the module file, but this is what made it work for me:
import Ember from "ember";
import gridLayout from "../utils/grid-layout";
export default Ember.Controller.extend({…
Links:
https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Statements/export
https://blog.abuiles.com/blog/2014/10/03/working-with-javascript-plugins-in-ember-cli/
In ember-cli version 2.11.0 by default its watching vendor foler.
https://github.com/ember-cli/ember-cli/pull/6436

How to test React Native classes that do not have a render method?

I am building a mobile application with React Native and ran into a problem when trying to unit test my code. Currently I do have both Jest and Enzyme being used in the testing.
How would I be able to test the methods in a certain class/file that does not contain a render() method and does not "extend as a Component"? This class is used to query information from an API and saving it into variables.
The documentation about Jest and Enzyme at
https://facebook.github.io/jest/docs/api.html#content
http://airbnb.io/enzyme/docs/api/index.html
seem to be focused on testing rendered components.
Assuming you've got a module export set up, you actually just import the object/class and then write a test against it using a jasmine syntax. You can try it out live right here:
https://facebook.github.io/jest/docs/getting-started.html#content
If you notice on the "add-test.js" file, the first line is a require to get your object under test. In this case:
const add = require('./add');
Then it's just a matter of regular old jasmine-style testing.

stubbing templates in RSpec functional tests

So I'm working on a gem that provides helpers for use with the Jeditable jQuery plugin, called jeditable-rails. These helpers are essentially writing javascript that create forms.
I am looking to stub templates within the request/controller specs, doing something like this:
gadget = Gadget.create!(:name => 'foo')
stub_template 'gadgets/edit.html.erb' => "<%= editable_field(#gadget, :name) %>"
# using Capybara
visit edit_gadget_path(gadget)
# fill out form, submit, etc.
When I run this in a request spec, I get the error undefined method 'stub_template'. Is it possible to use stub_template in request specs, or is there a different way to go about it?
This is Ruby, so it's probably possible, but it's not a given.
RSpec request specs delegate most of their work to Rails integration tests, which support multiple requests and, therefore, multiple controllers/views. stub_template requires access to a view instance, which we don't have access to in request specs.