Add API to trigger lifeCycles manually.
See original GitHub issueFeature Description
Some lifecycles are hard to be test in certain cases. For example, I have no idea on how to test activated
in shallowMount mode, since <keep-alive>
will be a stub. Howerver shallowMount is a MUST in my complicated applications.
Expected behaviour
provide an API like:
// does exacly what it says
// other lifeCycles should work, too.
wrapper.triggerLifeCycle('activated')
my solution for now (which works):
export function triggerLifeCycle(vm, lifeCycle) {
if (vm.$options[lifeCycle]) {
vm.$options[lifeCycle].forEach(fn => {
fn.call(vm);
});
}
}
if the idea sounds accepatble, I’m glad to make a PR. thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Setting lifecycle configuration on a bucket - AWS Documentation
This section explains how you can set a S3 Lifecycle configuration on a bucket using AWS SDKs, the AWS CLI, or the Amazon...
Read more >How to trigger a Lifecycle event - ServiceNow Community
Triggering a lifecycle event in ServiceNow can be done either automatically or manually. This blog post will lay out the steps for both....
Read more >Page Lifecycle API - Is it possible to manually freeze a page
I have simple event listeners to run a console.log when the either freeze or resume events are triggered. Does anybody know a way...
Read more >Create or update lifecycle policy API | Elasticsearch Guide [8.5]
The following example creates a new policy named my_policy . In addition, you can use the _meta parameter to add arbitrary metadata to...
Read more >Get or set lifecycle configuration for a bucket | Cloud Storage
Sets the lifecycle management configuration on one or more buckets. The config-json-file specified on the command line should be a path to a...
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 FreeTop 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
Top GitHub Comments
@bponomarenko Thank you very much for the kind answer and solution. You do solved my problem in a way that I have not consider yet. And I kind of agree your point about testing indeed. Good day.
I have been working with Vue codebases for around 3-4 years, and in my experience such “granular” unit tests usually hard to maintain and they break to0 often without tangible reasons. Fixing those “false positives” takes more time than the actual value they bring.
But let me try to address your questions: