Feature Request: ComponentStub helper
See original GitHub issueI’ve added this helper in my own codebase, but if useful to this project I’m happy to submit a PR. The code is below.
export function ComponentStub(name) {
this.rendered = false;
this.name = name;
this.render = (h) => {
this.rendered = true;
return h();
};
}
export default function componentStub(component, ...components) {
const stubs = {};
components.forEach((name) => {
stubs[name] = new ComponentStub(name);
});
component.components = { ...component.components, ...stubs };
}
Usage is simple:
import { shallow } from 'avoriaz';
import { componentStub } from '@/lib/avoriaz';
import Component from './Component';
componentStub(Component, 'router-link', 'router-view');
As a small bonus it provides stub telemetry for the render function.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
can not stub/mock helper methods #396 - ruby-grape ... - GitHub
for instance, I have a helper method named current_user, it returns the obvious value. I want to test an api request, once when...
Read more >How to stub a Rails helper/module method in Rspec 3 feature ...
I've seen this done using the older should_receive syntax, but I can't figure out how to stub a Rails module method in Rspec...
Read more >Using RSpec Stub and Mock | Cloudbees Blog
Stubbing and Mocking makes your component examples independent of other components. You can stub methods on objects to let them return ...
Read more >How to test software: mocking, stubbing, and contract testing
A great application of mocks and stubs in a unit/component test is when your implementation interacts with another method or class. You can...
Read more >Build a Mocking Framework with the Stub API
createStub () method. This feature is intended for advanced Apex developers. Using it requires a thorough understanding of unit testing and mocking frameworks....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ndabAP no I’ll continue to support and evolve it, but most of my time will be spent on vue-test-utils
@chrisnicola yes good idea on the array for
options.stub
. I’ll add it to the todo