Команда монтирования с помощью Next.js useRouter (/app router)

1
7

У меня начались ошибки (показанные ниже), когда я использовал useRouter из 'next/navigation' в моем приложении Next.js 14.2.5 (с маршрутизатором /app). Я попытался настроить команду nextMount в соответствии с этим руководством, но не могу заставить ее работать: https://www.cypress.io/blog/component-testing-next-js-with-cypress

Это руководство, похоже, больше относится к маршрутизатору /pages, а не /app. Как настроить команду монтирования, которая может использовать хук next/navigation useRouter в приложении маршрутизатора /app?

Кажется, в этом руководстве предлагается добавить code JSX в файл cypress/support/component.ts, файлы .ts не могут иметь синтаксис JSX...?

Буду очень признателен за любые указания :pray:

viewport375, 667
(uncaught exception)Error: invariant expected app router to be mounted
(uncaught exception)Error: invariant expected app router to be mounted
(uncaught exception)Error: invariant expected app router to be mounted
Error
The following error originated from your application code, not from Cypress.

> invariant expected app router to be mounted

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the uncaught:exception event.

Because this error occurred during a before each hook we are skipping the remaining tests in the current suite: on route 
Элеонора
Вопрос задан11 июня 2024 г.

1 Ответ

2
Милий
Ответ получен11 сентября 2024 г.

Ваш ответ

Загрузить файл.