CFHxKai
CFHxKai
NNuxt
Created by CFHxKai on 11/11/2024 in #❓・help
How can I know how much times a method inside the mocked composable was called in a test?
@kapa.ai for the method handleMyBtnClick in the component not work. AssertionError: expected "handleMyBtnClick" to be called 4 times, but got 0 times
11 replies
NNuxt
Created by CFHxKai on 11/11/2024 in #❓・help
How can I know how much times a method inside the mocked composable was called in a test?
For the composable method worked... xD
11 replies
NNuxt
Created by CFHxKai on 10/23/2024 in #❓・help
How to prevent navigation in nested routes?
1. give the same problem reported. 2. I think not work in this case because middleware run after leave and before enter (right? :P), and if leave the page I will lost page/components states (form changes). 3. do the trick, but need clean the beforeEach on leave (unmount page) to prevent register a new listener in each page change:
const router = useRouter();

const stop = router.beforeEach(() => {
if (!myForm.value?.isDirty) return;

if (!confirm('You have unsaved changes. Are you sure you want to leave?')) {
return false;
}
});

onUnmounted(() => {
stop();
});
const router = useRouter();

const stop = router.beforeEach(() => {
if (!myForm.value?.isDirty) return;

if (!confirm('You have unsaved changes. Are you sure you want to leave?')) {
return false;
}
});

onUnmounted(() => {
stop();
});
Don't know if is the better solution, but I don't find a better way to solve. ^^ Thank you... 😉
6 replies